-
-
Notifications
You must be signed in to change notification settings - Fork 670
Improve Signature lookups, Make Signature immutable #2582
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
Conversation
…on being is because signature type lookups have become a big bottleneck for libraries that have a lot of type signatures. We can uniquely identify these signatures by calculating their string representation using signature.toString(). This causes a lot of not so very straightforward problems within the compiler, the program, and the resolver. For instance, the compiler now has to call the `newStub` function with the maximum arguments, and when resolving a type in the resolver, we are not allowed to simply modify the return type of signatures, and instead we create a new one to obtain the proper function type id at instantiation time. Changes involved: - compiler tests fixtures updated - Signatures are now immutable - Some changes involving signatureReference equality have changed
After some local testing, I got some really amazing speed increases. I tested nearly 250k function signatures in that list, and the time it took to deal with them reduced to thirty seconds instead of a whopping 25 minutes (or more.) This can be regarded as a generalized improvement. |
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.
Overall looks good to me, modulo comments :)
Remove comments Co-authored-by: dcode <[email protected]>
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 didn't think of this, but .new
isn't the best name for this. .create
would be better.
Also, there is a stray output.txt
file.
src/resolver.ts
Outdated
let signature = new Signature(this.program, parameterTypes, returnType, thisType); | ||
signature.requiredParameters = requiredParameters; | ||
signature.hasRest = hasRest; | ||
let signature = Signature.new(this.program, parameterTypes, returnType, thisType, requiredParameters, hasRest); |
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.
let signature = Signature.new(this.program, parameterTypes, returnType, thisType, requiredParameters, hasRest); | |
let signature = Signature.create(this.program, parameterTypes, returnType, thisType, requiredParameters, hasRest); |
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.
Looking good, thanks! :)
In this pull request, the Signature class becomes immutable. The reason being is because signature type lookups have become a big bottleneck for libraries that have a lot of type signatures. We can uniquely identify these signatures by calculating their string representation using signature.toString(). This causes a lot of not so very straightforward problems within the compiler, the program, and the resolver. For instance, the compiler now has to call the
newStub
function with the maximum arguments, and when resolving a type in the resolver, we are not allowed to simply modify the return type of signatures, and instead we create a new one to obtain the proper function type id at instantiation time.Changes involved:
⯈
⯈
⯈