improve performance of Ember.guidFor and Ember.generateGuide on #4158
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.
Ember.Objects
Ember's guidKey uses defineProperty so that it is not enumerable,
this is a great idea, but can cost be a hard hit. Luckily though,
we pre-shape all ember objects to have a GUID_KEY slot. Unfortunately,
in guidFor and generateGuid we redefine the property. Not only is this
wasteful, but Object.defineProperty is incredibly costly.
Some micro-benchmarks:
more to come.
The cost of
guidFor
is about 5 - 10 times faster onEmber.Object
s, and can still be improved.and the cost to Object.create seems essentially 0. Their is a slight memory usage increase for never guid'd Ember.Object's as they store their guid Number.
If we continue to need guid's I wonder if we should always store them merely as the integer value.
related, @ebryn is working on some directions which mitigate the need for defineProperty on some objects (like views). If we can drop these safely across the board it would be a large win.