-
Notifications
You must be signed in to change notification settings - Fork 107
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
Rewrite MarshalGeneric<T> to minimize binary size on NativeAOT #1437
Merged
Sergio0694
merged 17 commits into
staging/AOT
from
user/sergiopedri/trim-marshal-generic
Jan 18, 2024
Merged
Rewrite MarshalGeneric<T> to minimize binary size on NativeAOT #1437
Sergio0694
merged 17 commits into
staging/AOT
from
user/sergiopedri/trim-marshal-generic
Jan 18, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Publishing this, as I think it's in a decent state now and covering almost all scenarios. There's just one unit test that's failing only on .NET Core 3.1 for some reason, @manodasanW if you can I'd love a second pair of eyes on that whenever you have time 😄 |
Sergio0694
force-pushed
the
user/sergiopedri/trim-marshal-generic
branch
2 times, most recently
from
January 14, 2024 16:21
3d3ea0b
to
c1f9a4d
Compare
Sergio0694
force-pushed
the
user/sergiopedri/trim-marshal-generic
branch
from
January 18, 2024 01:15
0b2067b
to
668af76
Compare
manodasanW
reviewed
Jan 18, 2024
manodasanW
approved these changes
Jan 18, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR completely rewrites
MarshalGeneric<T>
, to reduce the binary size. Currently there's over 200 KB just in delegate size coming from various generic instantiations for this class alone. Probably much more if we consider all the rest of the code. This PR changes the structure of the class to use a static constructor where we do trimmable type switches and also optimize for lots of well known cases for primitive types and other ABI types that we know will always get constructed. Additionally, I've also introduced a much more compact system of constructing delegates for the various generated methods on the helper types coming from the generated projections, which also skip all those generated closures.Here's what sizoscope is showing on a minimal WinRT component, for reference: