Skip to content

Avoid namespace formatting in ILLink analyzer type checks - #134732

Merged
tannergooding merged 2 commits into
dotnet:mainfrom
tannergooding:tannergooding-illink-analyzer-performance
Oct 8, 2026
Merged

tannergooding merged 2 commits into
dotnet:mainfrom
tannergooding:tannergooding-illink-analyzer-performance

Conversation

@tannergooding

Copy link
Copy Markdown
Member

Summary

ILLink's Roslyn analyzer checks many type symbols against a small set of well-known types. The previous lookup formatted a symbol's containing namespace before ruling out mismatched type names, creating avoidable work and allocations in large generated compilations.

Check the metadata name first so mismatches skip namespace formatting. Handle Roslyn special types directly and compare the requested namespace/name for other types, preserving the existing result for invalid well-known-type values. Add positive and negative analyzer tests that verify diagnostics and locations for well-known, derived, and unrelated types.

Performance

On Windows x64 with SDK 11.0.100-rc.1.26420.103, a synthetic interop-shaped compilation of 20,001 files and 160,000 methods was rebuilt in Release with ILLink, NET analyzers, and XML documentation enabled. Eight warmed, interleaved full-rebuild pairs compared the original analyzer with the final implementation:

Elapsed build time Original Changed
Median 32.30 s 25.32 s

Median paired saving: 7.20 s. The three ILLink warning lines matched exactly in every pair. These are elapsed build times, not concurrent aggregate analyzer seconds. The synthetic .NET 11 workload is representative of a large partial-heavy compilation; it does not measure the motivating TerraFX net10 Debug build.

Validation

51 focused ILLink analyzer tests passed, including data-flow and generated-code coverage.

Note

This PR description was drafted with GitHub Copilot.

@dotnet-policy-service dotnet-policy-service Bot added the linkable-framework Issues associated with delivering a linker friendly framework label Sep 27, 2026
@github-actions github-actions Bot added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Sep 27, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@tannergooding

Copy link
Copy Markdown
Member Author

This was notably a significant measurable bottleneck for TerraFX.Interop.Windows and I root caused it via a build profile down to these APIs.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/illink
See info in area-owners.md if you want to be subscribed.

@sbomer sbomer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@sbomer sbomer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@tannergooding
tannergooding merged commit 4996b8a into dotnet:main Oct 8, 2026
90 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Oct 13, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-Tools-ILLink .NET linker development as well as trimming analyzers linkable-framework Issues associated with delivering a linker friendly framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants