Repository navigation
[release/11.0] ILC: only keep type loader candidate type map entries when their generic arguments are present - #137857
Conversation
…ric arguments are present Backport of dotnet#137541 to release/11.0. Two ILC rules eagerly construct every generic type map key whose canonical form has a type loader template: the proxy type map rule added by dotnet#123031, and RuntimeConstructableTypeDependencies.AddTypeLoaderDependencies, called for external type map entries and unmanaged entry point source types. With a large number of generic instantiations (such as the CsWinRT 3.0 interop type maps) this keeps a large number of types alive. Only construct such a type if every generic argument is present in the compilation or can itself be created by the type loader. This is expressed with a chain of TypeLoaderArgumentGateNode conditional dependencies, one per argument, since a conditional dependency can only be conditioned on a single node. The element type of an array is treated as its only argument. This adapts the change to the dependency analysis API in release/11.0 (GetConditionalStaticDependencies returning IEnumerable instead of the DependencySink based API in main) and adds the TestInteropMapTypeLoaderKeys smoke test. Co-authored-by: Copilot App <[email protected]>
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
|
Could you update this to match the PR in main? Copilot says: The compiler changes appear equivalent after the API adaptation, but the backport is missing the original PR’s final test updates: multi-argument cases and changes that prevent proxy and external tests from masking each other’s failures. Not identical: the backport omits the original PR’s final test updates. Its The unexpected differences are:
Across the five compiler/project files, I found no differences beyond the expected dependency-analysis API adaptations. The test file can be copied unchanged from the merged original. |
Backport of the final test update of dotnet#137541: add the multi-argument cases for the proxy and external type map rules, and use distinct generic arguments for the proxy and external cases so retaining one map's key cannot mask a failure in the other. Co-authored-by: Copilot App <[email protected]>
Backport of #137541 to release/11.0
Customer Impact
20+% size regression when compiling Microsoft Store with .NET 11 compared to .NET 10.
Regression
Interop type maps had an analysis hole where we would not keep type map entries for types that could be loaded dynamically at runtime (as opposed to types that are statically present at compile time). The holes were fixed in #123031 and #126382, however the fix was rather conservative: keep type map entries if a type loader template exists for the type. The conservative choice caused impossible types to be kept, leading to the size regression beyond what's reasonable (it was known these correctness fixes would be size regressions).
This PR further restricts the rule to "type loader template exists and types used as generic arguments could exist".
Testing
Targeted trimming test was added.
Why this was missed: There was no data on Windows Store size with .NET 11 before we shipped GA. We have not seen regressions in other interop scenarios that use type maps (iOS/Android) and we measure, likely because they don't have generics at all.
Risk
The risk is low. The additional restriction makes sense, the fix is obvious, and was validated E2E with Store.