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

[BUGFIX release] Avoid unnecessary change events during initial render #11935

Merged
merged 3 commits into from
Jul 31, 2015

Conversation

ef4
Copy link
Contributor

@ef4 ef4 commented Jul 31, 2015

This change reduces unnecessary event firing during the initial render of each component. In my sample scenario, it cut average events per component from 14.9 to 7.07.

(The seven remaining events are the ones that are supposed to fire once each: didInitAttrs, didInsertElement, didReceiveAttrs, didRender, init, willInsertElement, and willRender.)

The impact on actual render time is not necessarily large (a few scenarios I looked at improved by up to 10%), but applications that are doing more expensive work in their observers may see bigger benefits.

This change is based on @stefanpenner's investigation in this comment. It's built on top of @rwjblue's PR #11934, since it would otherwise conflict and is attacking a related problem.

My changes are relatively small, you can see them in isolation here.

rwjblue and others added 3 commits July 30, 2015 22:21
Previously, when `positionalParams` was a string value (which means to
set all params as an array at that particular prop in `attrs`) we were
iterating over the length of the destination property name instead of
the available `params`.
This significantly reduces unnecessary event firing during the initial
render of each component. In my sample scenario, it cut average events
per component from 14.9 to 7.07.

This does not have a major performance impact by itself, but
applications that are observing any of these events may experience
improvement.
@ef4 ef4 changed the title Avoid unnecessary change events during initial render [BUGFIX release] Avoid unnecessary change events during initial render Jul 31, 2015
@stefanpenner
Copy link
Member

Im seeing 10% - 15% improved render times, and this looks good to me.

I have found some more work amplfications. Will report shortly.

@rwjblue
Copy link
Member

rwjblue commented Jul 31, 2015

There is no semantic change here, 'this.attrs' was already available at component 'init', the main difference is that we avoid 'set(component, "attrs", attrsSnapshot)' (after having just set/passed those attrs when creating the component anyways).

I'm very 👍

stefanpenner added a commit that referenced this pull request Jul 31, 2015
[BUGFIX release] Avoid unnecessary change events during initial render
@stefanpenner stefanpenner merged commit facb04b into emberjs:master Jul 31, 2015
@sandstrom
Copy link
Contributor

@ef4 Awesome Edward! 😄

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 this pull request may close these issues.

4 participants