-
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 typeof(T).GUID an intrinsic on NAOT where possible (like .NET Native) #95184
Comments
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas Issue DetailsDescriptionEspecially in interop scenarios, it's rather common to use Configuration.NET 8.0.100 Regression?No, always been this way. DataThis is a screenshot from @MichalStrehovsky's sizoscope tool, from a ComputeSharp sample, after removing This is from Sergio0694/ComputeSharp#669. Just this saved a total of 304 KB in my sample. Here's some precompiled diffs with MSTAT info, for baseline and with that PR applied to it: native-guid_diffs.zip.
|
…ttribute reader Fixes dotnet#95184
This cruft was pulled in by universal custom attribute reader that handles all types that can show up in custom attributes. Most of it was the type loader that is not really reflection. #95212 removes this dependency by using a reader that just handles strings (the only case required for GuidAttribute).
I do not think it makes sense to complicate JIT with this. |
Description
Especially in interop scenarios, it's rather common to use
typeof(T).GUID
to get theGuid
associated with a given type. This currently causes a whole lot of reflection cruft to be preserved, which just on its own can exceed 300 KB of stuff, purely rooted bytypeof(T).GUID
. I was wondering whether it would be possible to make this an intrinsic, at least for NativeAOT. In theory, shouldn't the compiler always have all the necessary information to compute the GUID ahead of time? Or at least, could it not do that in all cases where the typeT
has the[Guid]
attribute applied to it? IIRC, .NET Native has a similar optimization, where it can just bake all of thesetypeof(T).GUID
uses directly into the codegen, making this pretty much free.Could we do the same on NativeAOT?
Configuration
.NET 8.0.100
Regression?
No, always been this way.
Data
This is a screenshot from @MichalStrehovsky's sizoscope tool, from a ComputeSharp sample, after removing
typeof(T).GUID
:This is from Sergio0694/ComputeSharp#669. Just this saved a total of 304 KB in my sample.
Here's some precompiled diffs with MSTAT info, for baseline and with that PR applied to it: native-guid_diffs.zip.
Note
Related to #91518.
The text was updated successfully, but these errors were encountered: