-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Removes hasOwnProperty
checks to improve overall performance.
#2213
Conversation
Tested using a real application, it can be found [here](https://github.com/stefanpenner/perf-stress). Fixes #2206. `normalizeAttributes` before:  after:  `normalizeRelationships` before:  after the change, it doesn't get registered. thanks to @stefanpenner for pointing it out.
Are we somehow making jquery return a hash with Object.create(null)? Otherwise I don't see how this works out? cc @stefanpenner |
The problem with removing those checks is that the normalization will end up by adding undefined value to the hash, and we don't want that. see #2104. That beeing said, I don't know why the tests are passing... I must have missed something |
Then just guard against undefined. That code path is optimized in runtimes correctly. Has own prop is still crazy slow |
@stefanpenner I'm not sure it's the same.
Imagine we want to |
@sly7-7 we are reading from in theory |
@stefanpenner I think always converting to null is not an option, this will not work for partial normalization because it would end up to replace all the currently defined attributes to null. |
does partial materialization even make sense? Seems like a great way to introduce zalgo at the model layer. |
The goal of #2104 was to make store.normalize beeing able to work with store.update. To make this work, store.normalize should not add extra {key: null} pairs to the normalized hash. Maybe it was just a bad idea, but in that case, I think we have to find an other way to update a record. |
@sly7-7 if memory serves me correctly I think at the last ember data meeting tomhuda and igor decided we're going to deprecate "update" and let people opt into merging behavior with their serializer. |
@fivetanley I don't know when was the last meeting, but if your're right, I think #2104 should be reverted, and #2193 should be closed. I just don't know if those comments were before or after the meeting. |
@stefanpenner @igorT @fivetanley Was there any other discussions about those fu**** hasOwnProp ? |
This seems related to #2472 |
I am not sure we can do this. We will end up cloberring data. Also, the perf difference seems like ~ 2% |
just remember 10 2% wins === 20% if you don't think its worth it, then thats your call. But I would encourage seeing what needs to change so we can avoid this as it merely compounds with other perf issues. |
The only way I can think of is to change the serializer implementation to iterate over the provided hash vs iterating over record attrs. But then we have to use Object.keys, not sure whether that will be faster/slower. Also would break all the keyForAttribute methods people defined themselves |
@igor splitting the concept of patch vs general update is also a solution |
im not sure where you are seeing 2% as his benchmark was likely the result of a much larger experiment then a specialized |
@stefanpenner that would cause us to have double the serializer methods. |
Tested using a real application, it can be found here.
Fixes #2206.
normalizeAttributes
before:

after:

normalizeRelationships
before:

after the change, it doesn't get registered.
thanks to @stefanpenner for pointing it out.