-
Notifications
You must be signed in to change notification settings - Fork 2
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
Faster constructor #66
Conversation
ed8b219
to
a75036e
Compare
this[$env] = context.env; | ||
this[$parent] = parent; | ||
|
||
(this.constructor as IClassModelType<any>)[$fastInstantiator](this as any, snapshot, context); |
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 call was megamorphic before -- all the MQT classes subclass this one, and then this class ends up calling the instantiator. Because they all share the same parent class, this callsite is shared among all of em! Instead of generating this function, we can instead generate a child class that hardcodes the instantiation logic right in its constructor. Super duper monomorphic!
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.
So simple, but so effective!
411a446
to
b43d39e
Compare
…e instance constructor
a75036e
to
1490d2b
Compare
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.
Majestic!
this[$env] = context.env; | ||
this[$parent] = parent; | ||
|
||
(this.constructor as IClassModelType<any>)[$fastInstantiator](this as any, snapshot, context); |
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.
So simple, but so effective!
On top of #65
15% improvement by removing a megamorphic call to the fast instantiator function! Yeesh!
On
perf-improvements
:On this branch: