-
-
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
[PERF] make internal model lazier #4562
Conversation
so excited 🙏 we'll have to make sure we don't break @BookingSync's and others' addons. |
@fivetanley this provides identical private API's to what was present before, they are just lazy, with one notable exception. I've removed the use of |
yeah i am not really concerned about the api changing here, just a last step before merging to run it against addons that use |
Also note, the tests on this pass locally but I need to rebase off master for them to pass here, If we could merge heimdall today I've got a follow up PR after this one that's also fun :) |
2b28f97
to
4fba4a9
Compare
@igor rebase complete |
|
||
// these are here to prevent shape change later when Ember lookups add them | ||
this.__ember_meta__ = null; | ||
this[GUID_KEY] = guidFor(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't believe the left hand side here is required
changedKeys.push(key); | ||
} | ||
} | ||
} | ||
|
||
return changedKeys; | ||
}, | ||
} | ||
|
||
toString() { | ||
if (this.record) { | ||
return this.record.toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this branch seems un-needed
@@ -584,6 +584,7 @@ var RootState = { | |||
}, | |||
|
|||
didCommit(internalModel) { | |||
// TODO @runspired lastDirtyType doesn't seem to be a real thing | |||
internalModel.send('invokeLifecycleCallbacks', get(internalModel, 'lastDirtyType')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^ todo + get, if its not used then this line may be a candidate for removal
let i; | ||
let l; | ||
|
||
if (TransitionChainMap[transitionMapId]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe let map = TransitionChainMap[transitionMapId]
then reference map everywhere
@@ -241,7 +244,7 @@ var DirtyState = { | |||
|
|||
//TODO(Igor) reloading now triggers a | |||
//loadingData event, though it seems fine? | |||
loadingData: Ember.K, | |||
loadingData: K, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets just do loadingData() { }
rather then the single shared function of K
@@ -4,7 +4,10 @@ | |||
import Ember from 'ember'; | |||
import { assert } from "ember-data/-private/debug"; | |||
|
|||
var get = Ember.get; | |||
const { | |||
K |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets not use K
regular concise functions are likely fine.
7baf19f
to
c0e567d
Compare
Eyeballing the production build benchmarks (no filtering of outliers but I am looking at a box plot), we moved from roughly 35ms spent in |
LGTM 👍 |
|
||
const assign = Ember.assign || Ember.merge; | ||
const setOwner = Ember.setOwner; | ||
const TransitionChainMap = new EmptyObject(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you put a comment here or in the method as to how the transitionchain map works
374ea89
to
475d9aa
Compare
@@ -305,6 +308,7 @@ var Model = Ember.Object.extend(Ember.Evented, { | |||
@private | |||
@type {Object} | |||
*/ | |||
currentState: null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we define this on the prototype?
@@ -430,7 +433,7 @@ createdState.uncommitted.pushedData = function(internalModel) { | |||
internalModel.triggerLater('didLoad'); | |||
}; | |||
|
|||
createdState.uncommitted.propertyWasReset = Ember.K; | |||
createdState.uncommitted.propertyWasReset = K; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
= function() { }
475d9aa
to
5afa263
Compare
@igorT Travis is passing after making the changes from @stefanpenner's last review. |
5afa263
to
a28fb00
Compare
- allocations are now lazy - InternalModel is now an ES2015 class, the expensive classCallCheck is stripped via a babel plugin - TransitionMapCache has been added to make transitionTo function faster - get/set of currentState has been moved to dot notation access - overall this appears to be a 20% perf improvement, with more gains still realizable.
Branches off of heimdall-instrumentation, so that should be merged fist ;)