Skip to content

[TrimmableTypeMap] Skip redundant assembly reference scans - #12440

Merged
jonathanpeppers merged 1 commit into
mainfrom
dev/simonrozsival/skip-known-typemap-assembly-scans
Aug 19, 2026
Merged

jonathanpeppers merged 1 commit into
mainfrom
dev/simonrozsival/skip-known-typemap-assembly-scans

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Aug 19, 2026 •

Copy link
Copy Markdown
Member

Related: #10958

Summary

  • mark generated trimmable typemap publish items with HasMonoAndroidReference=true
  • preserve information already known by the typemap generator instead of reopening every generated DLL
  • apply the same metadata when replacing linked typemaps with ReadyToRun outputs

ProcessAssemblies determines whether each publish assembly references Mono.Android. When the item metadata is absent, it opens the DLL with PEReader and scans its assembly-reference table. Trimmable Debug builds add approximately 82 generated typemap DLLs to ResolvedFileToPublish; all of them are known to reference Mono.Android, making those file opens redundant.

This issue and fix both exist independently on main; no pregenerated framework typemap changes are required.

Performance

Five clean MAUI Debug Android builds before and after the metadata change:

ProcessAssemblies Before After Improvement
Mean 2.731s 0.162s 2.569s / 94.1%
Median 3.132s 0.122s 3.010s / 96.1%
Runs 3.384, 3.132, 2.454, 3.723, 0.964s 0.383, 0.123, 0.092, 0.122, 0.089s

A separate clean validation build from this main-based branch measured ProcessAssemblies at 0.187s.

Validation

  • built Xamarin.Android.Build.Tasks
  • clean dotnet new maui Debug Android build with the trimmable typemap
  • captured a binlog and confirmed ProcessAssemblies completed in 0.187s

Mark generated typemap publish items as known Mono.Android references so ProcessAssemblies does not reopen and scan every per-assembly typemap DLL.

Co-authored-by: Copilot <[email protected]>
Copilot AI lite review requested due to automatic review settings August 19, 2026 13:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves publish-time performance for trimmable TypeMap builds by preserving already-known assembly metadata instead of having ProcessAssemblies reopen and scan each generated TypeMap DLL to detect a Mono.Android reference.

Changes:

  • Adds HasMonoAndroidReference=true metadata to generated trimmable TypeMap assemblies added to ResolvedFileToPublish, avoiding redundant PE/metadata scans.
  • Applies the same metadata when swapping linked TypeMaps for ReadyToRun TypeMap outputs to keep the optimization consistent.
Show a summary per file
File Description
src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.CoreCLR.targets Marks generated/ReadyToRun TypeMap publish items with HasMonoAndroidReference=true so ProcessAssemblies can skip reopening and scanning these known Mono.Android-referencing assemblies.

Review details

  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

@jonathanpeppers
jonathanpeppers merged commit 7faa212 into main Aug 19, 2026
45 checks passed
@jonathanpeppers
jonathanpeppers deleted the dev/simonrozsival/skip-known-typemap-assembly-scans branch August 19, 2026 17:36
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants