Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can.stache performance #1011

Closed
yusufsafak opened this issue May 22, 2014 · 10 comments
Closed

can.stache performance #1011

yusufsafak opened this issue May 22, 2014 · 10 comments
Milestone

Comments

@yusufsafak
Copy link
Contributor

Hi,
I found this script http://jsfiddle.net/rich_harris/R9HRM/ and tried to measure performance of can.stache in http://jsfiddle.net/yusufsafak/NtBGL/ . The performance of can.stache is really bad when compared to other libraries.  Am I missing something?

Thanks,
Safak

@justinbmeyer
Copy link
Contributor

Thanks for bringing this to my attention. I just checked my benchmark and somehow stache performance is about 2x as slow as I left it. I'll dig into it and discover why. My guess is that a bug was fixed in a non optimal way.

@justinbmeyer
Copy link
Contributor

So, this branch https://github.com/bitovi/canjs/tree/stache-perf has about 25% improvement (from 13ms to 9ms) where html bars is about 3ms.

About 3ms of that difference seems to be how we are setting attributes so they "might" publish DOM modification events and we will set cssText for IE8 compatibility.

The rest of it seems to be around our events and computes. We used to have live-binding not create a compute. We might restore that.

@justinbmeyer
Copy link
Contributor

So much of the remaining performance difference has to do with the way CanJS sets up live binding. Ember does not support computed methods without explicitly specifying bindings. CanJS does. CanJS uses the technique for computed methods when evaluating something like:

{{content}}

This technique involves calling a function, seeing what can.__reading calls it makes, comparing it with previous can.__reading calls. That's unnecessary for a binding like {{content}}.

I think we can improve performance significantly by optimizing for simple observable property binding.

justinbmeyer added a commit that referenced this issue May 24, 2014
@justinbmeyer
Copy link
Contributor

That gets CanJS down to 5ms per loop. This makes CanJS faster than all the live binders except HTMLBars which is 3.6ms. I think this is sufficient gains to be included in a 2.1.2.

Future gains can be had by:

  • removing the "extra" compute in attributes that are all mustache.
  • improving can.attr.set so it doesn't check MutationObserver.
  • improving attrParts performance

justinbmeyer added a commit that referenced this issue May 24, 2014
@justinbmeyer
Copy link
Contributor

Down to 4.2ms.

@justinbmeyer
Copy link
Contributor

If someone pulls this ... they should try to remove attrParts completely.

@ccummings ccummings added this to the 2.1.2 milestone May 26, 2014
@Bajix
Copy link

Bajix commented May 30, 2014

Set up a decent performance fiddle to gauge dom manipulation, hope it helps!
http://jsfiddle.net/RtYxL/

@daffl
Copy link
Contributor

daffl commented Jun 10, 2014

@justinbmeyer Is there a pull request for getting the stache perf branch into 2.1.2?

@justinbmeyer
Copy link
Contributor

doesn't seem like it.

Justin Meyer
847-924-6039

On Tue, Jun 10, 2014 at 4:25 PM, David Luecke notifications@github.com
wrote:

@justinbmeyer https://github.com/justinbmeyer Is there a pull request
for getting the stache perf branch into 2.1.2?


Reply to this email directly or view it on GitHub
#1011 (comment).

@daffl
Copy link
Contributor

daffl commented Jun 11, 2014

Closed through the commits in #1048

@daffl daffl closed this as completed Jun 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants