Repository navigation
[MAUI] Measure only APK in Android SOD jobs - #5265
Merged
LoopedBard3 merged 1 commit intoJul 27, 2026
Merged
Conversation
Stage only the signed APK and versions metadata for Android SizeOnDisk work items so mapping files, binlogs, and other publish sidecars are not reported as APK size. Co-authored-by: Copilot <[email protected]> Copilot-Session: a301fa68-0e6c-4280-b2f2-bc3d4c9ae3de
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes MAUI Android SizeOnDisk (SOD) measurements in Helix by staging only the signed APK (plus versions.json) into the pub directory, avoiding accidental inclusion of extra publish artifacts (e.g., R8 mapping.txt, binlogs, resource-designer assemblies) in the “APK size” metric.
Changes:
- Update Android SOD work item pre-commands to copy only
*.apkandversions.jsonintopubinstead of recursively copying the entire correlation output. - Keep the extracted-APK measurement behavior by still expanding the APK contents into
pubfor the “Extracted Size” work item.
Show a summary per file
| File | Description |
|---|---|
| eng/performance/maui_scenarios_android.proj | Adjusts Android SOD Helix work items to stage only the intended measurement inputs (APK + versions metadata) into pub to prevent inflated size reporting. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 0
matouskozak
approved these changes
Jul 24, 2026
LoopedBard3
approved these changes
Jul 27, 2026
simonrozsival
added a commit
to dotnet/android
that referenced
this pull request
Aug 25, 2026
## Summary - enable DGML-filtered R8 keep rules by default for optimized NativeAOT trimmable-typemap builds - emit only the scan graph in optimized builds or the codegen graph in unoptimized explicit opt-ins, instead of always producing both - serialize graph-producing multi-RID NativeAOT builds to avoid system file-table exhaustion - stop DGML parsing after the `Nodes` section and add runtime-host/incremental coverage ## Context Related to #12184. The performance-chart discontinuity is separately addressed by dotnet/performance#5265, but the APK investigation found real Java-side over-retention. With Java trimming disabled, R8 keeps all 13,007 Java names from `acw-map.txt`, even though ILC retains only 1,132 typemap records for this app. For `dotnet new maui --sample-content`, `android-arm64`, Release NativeAOT: | Metric | Keep all Java types | Filtered keep rules | Delta | | --- | ---: | ---: | ---: | | Signed APK | 21,876,685 B | 18,931,603 B | -2,945,082 B | | Raw DEX | 13,626,844 B | 5,171,592 B | -8,455,252 B | | Java keep rules | 13,007 | 1,154 | -11,853 | | NativeAOT shared library | 32,019,032 B | 32,019,032 B | 0 B | The removed Java closure includes all 2,253 Tink classes, AndroidX Security Crypto, and thousands of unused AndroidX/Kotlin/Material classes. ## DGML and build impact The previous opt-in used `IlcGenerateDgmlFile=true`, which emitted both graphs: - scan DGML: 545,822,343 B - codegen DGML: 426,448,469 B - total: 972,270,812 B This change requests only the graph needed by the current compilation mode. A normal optimized build now writes only the 545,822,343-byte scan graph. Explicit `IlcGenerateDgmlFile=true` still produces both diagnostic graphs. Two warm-cache clean runs per mode on macOS arm64 measured: | Mode | Mean wall time | Mean peak RSS | DGML | | --- | ---: | ---: | ---: | | Java trimming off | 137.03 s | 2.29 GB | 0 B | | Previous full-DGML opt-in | 136.53 s | 3.15 GB | 972,270,812 B | | This change | 128.07 s | 2.65 GB | 545,822,343 B | The wall-clock impact is near-neutral because ILC/report generation is offset by R8 processing a much smaller retained Java graph. The remaining tradeoff is approximately 546 MB of intermediate disk per RID and roughly 0.36 GB additional peak RSS versus keeping all Java types. No-change publishes remain incremental (about 5-7 seconds): ILC and ProGuard generation skip, and the graph/config/APK timestamps remain unchanged. Source changes rerun ILC, while unchanged keep rules prevent unnecessary javac/R8/APK work. ## Correctness - Release defaults Java trimming on; Debug remains off because its 790 MB codegen graph produced no Java-size benefit. - A true -> false -> source change -> true sequence with a new retained Java peer regenerated the graph and retained the new peer. - Multi-RID graph generation is serialized after parallel ILC graph writers reproduced system file-table exhaustion. - The sample-content APK installed and launched on an API 36 arm64 emulator and survived 100 Monkey events without a Java class/method failure. ## Tests ```text ./dotnet-local.sh test bin/TestDebug/net10.0/Xamarin.Android.Build.Tests.dll \ --filter FullyQualifiedName~Execute_GenerateNativeAotProguardConfiguration ./dotnet-local.sh test bin/TestDebug/net10.0/Xamarin.Android.Build.Tests.dll \ --filter FullyQualifiedName~Build_WithTrimmableTypeMap_IncrementalBuild \ -- NUnit.NumberOfTestWorkers=1 ./dotnet-local.sh test bin/TestDebug/net10.0/Xamarin.Android.Build.Tests.dll \ --filter FullyQualifiedName~Build_WithTrimmableTypeMap_KeepsNativeAotRuntimeHostAcws \ -- NUnit.NumberOfTestWorkers=1 ``` ## Why not use `IlcGenerateDgmlFile`? The upstream `IlcGenerateDgmlFile=true` switch expands to both `--dgmllog` and `--scandgmllog`. For this sample that writes 426,448,469 bytes of codegen DGML plus 545,822,343 bytes of scan DGML (972,270,812 bytes per RID). The Android keep-rule task consumes only the scan graph in optimized builds. In unoptimized builds the scanner does not run, so it consumes only the codegen graph. This change passes the required argument directly to avoid generating the other several-hundred-megabyte file. Explicitly setting `IlcGenerateDgmlFile=true` continues to request and preserve both graphs for full ILC diagnostics. A cleaner long-term upstream API would expose independent scan/codegen DGML properties.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
versions.jsonfor MAUI Android SizeOnDisk work itemsBackground
Related: dotnet/android#12184
@matouskozak The NativeAOT MAUI sample-content chart jumped from roughly 27 MB to 53 MB after dotnet/android enabled the trimmable typemap by default. The trimmable path also enables R8, which publishes a large
mapping.txtbeside the APK.The SOD work item recursively copied the complete correlation output into
pub, andSizeOnDiskrecursively measured that directory. Running the unmodified scenario against a reproduced payload reported 52,797,806 bytes, comprising:mapping.txt: 28,318,349 bytesversions.json: 3 bytesThe actual trimmable APK is smaller than the previous managed-typemap APK; the regression is in measurement composition.
This change stages only the APK and
versions.jsonfor the two SOD work items.test.pyconsumes and removesversions.jsonin lab runs before invoking SizeOnDisk.Validation