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] Faster attrs-proxy #11946

Merged
merged 1 commit into from
Aug 2, 2015
Merged

Conversation

ef4
Copy link
Contributor

@ef4 ef4 commented Aug 1, 2015

The attrs-proxy exists to make component attrs available directly on the component instance, for compatibility with the pre-Glimmer world. This change makes the attrs-proxy significantly faster by implementing the proxy using Glimmer's lifecycle hooks instead of creating observers.

When first written, the attrs-proxy was also attempting to fire deprecations for every direct property access that went through it. We later removed that deprecation, but we're still paying the price for making a place to put it. When we re-add a similar deprecation we should ensure that it has no cost in production builds.

I also moved the didInitAttrs hook inside component init, so that changes made there do not trigger observers.

I condensed two distinct tests into one, because the subtle difference between the two scenarios has disappeared. The behavior change seems acceptable because this case is already covered under the double-render warning, so people will be told they're doing something with potentially undefined behavior.

Using a complex list benchmark that has been ported to idiomatic modern Ember, I'm measuring 56% faster rendering when compared to master. This takes us from 170% slower than 1.12 to 21% slower than 1.12. And much remains to still be optimized.

@ebryn
Copy link
Member

ebryn commented Aug 1, 2015

👏

@rwjblue
Copy link
Member

rwjblue commented Aug 1, 2015

👍 - Wonderful job @ef4!

@raytiley
Copy link
Contributor

raytiley commented Aug 1, 2015

Awesome!!!

values[prop] = this.getAttr(prop);
}
}
this.setProperties(values);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

although strange, set in a loop is typically faster, since the batching of setProperties comes at a cost.

Worth testing (if someone has time)

@stefanpenner
Copy link
Member

yay :)

The attrs-proxy exists to make component attrs available directly on the
component instance, for compatibility with the pre-Glimmer world. This
change makes the attrs-proxy significantly faster by implementing the
proxy using Glimmer's lifecycle hooks instead of creating observers.

I also moved the didInitAttrs hook inside component `init`, so that
changes made there do not trigger observers.

I condensed two distinct tests into one, because the subtle difference
between the two scenarios has disappeared. The behavior change seems
acceptable because this case is already covered under the double-render
warning, so people will be told they're doing something with potentially
undefined behavior.

Using [complex list
benchmark](https://github.com/ef4/initial-render-perf) that has been
ported to idiomatic modern Ember, I'm measuring 56% faster rendering
when compared to master. This takes us from 270% slower than 1.12 to 21%
slower than 1.12. And much remains to still be optimized.
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.

5 participants