-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Make generic composition information more efficient #85623
Conversation
Remove parameter count and flag. This is available in the generic definition MethodTable. Use `MethodTableList` instead of `EETypeRef`. This allows emitting the list as relative pointers.
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas Issue DetailsBefore this PR, we tracked information about generic composition of a
This works, but it's not particularly efficient, especially in light of some facts that didn't exist at the time this scheme was introduced. In particular:
This PR addresses all of the above. Saves about 0.5% in size for BasicMinimalApi, improves startup (the composition no longer needs to be dehydrated because it's relative pointers now), and improves working set (the composition stuff accounted for 100 kB of private dehydrated working set in BasicMinimalApi).
|
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.
Nice!
Very nice. Out of curiosity -- do we need type parameters often for instantiated types? My uninformed guess would be that we would need type arguments much more often. |
The code does not use these type parameters. If the shared generic code needs these type parameters, they will get duplicated in the generic dictionary where they are fast to access. These type parameters are only used for reflection and complex casts. Complex casts are behind a cache and so computing the answer of the complex cast is not perf critical. |
Before this PR, we tracked information about generic composition of a
MethodTable
this way:MethodTable
had a pointer to the generic definitionMethodTable
.MethodTable
had a pointer to its generic composition: a variable sized data structure that had a small header (number of elements, a flag whether it's variant), followed by pointers toMethodTable
s of components, optionally followed by variance information for each argument.This works, but it's not particularly efficient, especially in light of some facts that didn't exist at the time this scheme was introduced.
In particular:
This PR addresses all of the above.
Saves about 0.5% in size for BasicMinimalApi, improves startup (the composition no longer needs to be dehydrated because it's relative pointers now), and improves working set (the composition stuff accounted for 100 kB of private dehydrated working set in BasicMinimalApi).
Cc @dotnet/ilc-contrib