Skip to content
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

[.NET] Missing linker optimizations #11447

Open
sbomer opened this issue May 5, 2021 · 1 comment
Open

[.NET] Missing linker optimizations #11447

sbomer opened this issue May 5, 2021 · 1 comment
Labels
dotnet An issue or pull request related to .NET (6) enhancement The issue or pull request is an enhancement
Milestone

Comments

@sbomer
Copy link
Member

sbomer commented May 5, 2021

The .NET 6 linker no longer runs TypeMapStep for assemblies up-front. Instead the linker discovers base types on-demand (and the known overrides at any given point may be incomplete).

CoreTypeMapStep is not part of the .NET 6 macios linker pipeline, so some optimizations are not enabled:

  • IsNSObject checks are not cached
    • This used to be cached via HashSet, where anything not in the set is considered "false". In the new world we can't assume that all types have been seen, so this would have to become Dictionary<TypeDefinition, bool> or similar using the linker custom annotations
  • IsDirectBinding checks are not optimized (since they rely on information normally cached by CoreTypeMapStep)
    • Unless we scan some assemblies up-front, we won't know which wrapper types have derived types, so we'll probably need to keep scanning at least some assemblies before MarkStep. The pre-scan could be limited to assemblies which reference the product assembly.
    • As part of this, IsCIFilter also used to be cached. This could be done on type discovery with the new linker.

edit: another missed opportunity is that CollectUnmarkedMembersSubStep runs before MarkStep so it will effectively track all members. Ideally this step would run after Mark.

@sbomer sbomer changed the title [.NET 6] Missing optimizations [.NET 6] Missing linker optimizations May 5, 2021
@spouliot spouliot added dotnet An issue or pull request related to .NET (6) dotnet-pri1 .NET 6: important for stable release labels May 5, 2021
@spouliot spouliot added this to the .NET 6 milestone May 5, 2021
@spouliot
Copy link
Contributor

spouliot commented May 5, 2021

CoreTypeMapStep also control the possible removal of the dynamic registrar from the final app. I'm moving this out of CoreTypeMapStep since it has no real interaction with the base type (or other code / optimization).

However it does, like other parts, assume all potential assemblies are known/loaded to make the decision (to keep or not the dynamic registrar). That decision does influence the optimization done later (before at at marking time).

@rolfbjarne rolfbjarne removed the dotnet-pri1 .NET 6: important for stable release label Mar 29, 2022
@rolfbjarne rolfbjarne modified the milestones: .NET 6, .NET 7 Mar 29, 2022
@rolfbjarne rolfbjarne changed the title [.NET 6] Missing linker optimizations [.NET] Missing linker optimizations Mar 29, 2022
@rolfbjarne rolfbjarne added the enhancement The issue or pull request is an enhancement label Mar 29, 2022
@rolfbjarne rolfbjarne modified the milestones: .NET 7, .NET 8 Aug 26, 2022
@rolfbjarne rolfbjarne modified the milestones: .NET 8, .NET 9 Sep 12, 2023
@github-project-automation github-project-automation bot moved this to Technical Debt in .NET 9 Aug 27, 2024
@rolfbjarne rolfbjarne modified the milestones: .NET 9, .NET 10 Sep 27, 2024
@rolfbjarne rolfbjarne removed this from .NET 9 Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet An issue or pull request related to .NET (6) enhancement The issue or pull request is an enhancement
Projects
None yet
Development

No branches or pull requests

3 participants