[BUGFIX release] Faster attrs-proxy #11946
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.