Do not use ValueTuple in SynchronizationContext#87120
Do not use ValueTuple in SynchronizationContext#87120stephentoub merged 1 commit intodotnet:mainfrom
Conversation
This is the same issue as e.g. dotnet#84206. The compiler needs to consider delegate Invoke methods always reflectable because of trimming warning suppressions around this in the framework. But that means the compiler is going to create type loader templates for all types in the `Invoke` signature. If one of those is a `ValueTuple`, it will root the ability to runtime-create arbitrary comparers at runtime (`ValueTuple` annoying implements `Equals` using `EqualityComparer.Default`) and with it the entire type loader. For a sample app in dotnet#82607 this causes about 200 kB of bloat to be generated (more than 10% of the app size).
|
Tagging subscribers to this area: @mangod9 Issue DetailsThis is the same issue as e.g. #84206. The compiler needs to consider delegate Invoke methods always reflectable because of trimming warning suppressions around this in the framework. But that means the compiler is going to create type loader templates for all types in the For a sample app in #82607 this causes about 200 kB of bloat to be generated (more than 10% of the app size). Closes #82607.
|
|
The code generated by Roslyn for records and anonymous types uses EqualityComparer too, even for IEquatables and the well-known primitives. |
This is known - we recommend everyone who cares about the size impact not to use them unless they really need all the provided features (equality, hashcode, stringification, etc.) - they're going to pay for those even when they don't use them: dotnet/aspnetcore#45604 (comment) |
This is the same issue as e.g. #84206. The compiler needs to consider delegate Invoke methods always reflectable because of trimming warning suppressions around this in the framework. But that means the compiler is going to create type loader templates for all types in the
Invokesignature. If one of those is aValueTuple, it will root the ability to runtime-create arbitrary comparers at runtime (ValueTupleannoying implementsEqualsusingEqualityComparer.Default) and with it the entire type loader.For a sample app in #82607 this causes about 200 kB of bloat to be generated (more than 10% of the app size).
Closes #82607.