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

Comments

Projects
None yet
5 participants
@yusufsafak
Contributor

yusufsafak commented May 22, 2014

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

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer May 22, 2014

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.

Contributor

justinbmeyer commented May 22, 2014

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

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer May 22, 2014

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.

Contributor

justinbmeyer commented May 22, 2014

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

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer May 23, 2014

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.

Contributor

justinbmeyer commented May 23, 2014

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

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer May 24, 2014

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
Contributor

justinbmeyer commented May 24, 2014

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

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer May 24, 2014

Contributor

Down to 4.2ms.

Contributor

justinbmeyer commented May 24, 2014

Down to 4.2ms.

@justinbmeyer

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer May 24, 2014

Contributor

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

Contributor

justinbmeyer commented May 24, 2014

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

This comment has been minimized.

Show comment
Hide comment
@Bajix

Bajix May 30, 2014

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

Bajix commented May 30, 2014

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

@daffl

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Jun 10, 2014

Contributor

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

Contributor

daffl commented Jun 10, 2014

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

@justinbmeyer

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer Jun 10, 2014

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).

Contributor

justinbmeyer commented Jun 10, 2014

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

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Jun 11, 2014

Contributor

Closed through the commits in #1048

Contributor

daffl commented Jun 11, 2014

Closed through the commits in #1048

@daffl daffl closed this Jun 11, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment