Skip to content

[build] Increase release assembly store compression - #12415

Merged
jonathanpeppers merged 3 commits into
mainfrom
dev/simonrozsival/zstd-max-release
Aug 19, 2026
Merged

jonathanpeppers merged 3 commits into
mainfrom
dev/simonrozsival/zstd-max-release

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Aug 18, 2026 •

Copy link
Copy Markdown
Member

Summary

  • use the maximum Zstandard compression level (22) for optimized builds
  • retain compression level 3 for non-optimized builds
  • preserve explicit $(_AndroidAssemblyStoreCompressionLevel) overrides
  • add build-test coverage for Debug, Release, and explicit compression-level selection
  • update CoreCLR APK size references for the intended assembly-store size reduction

Results

Measured using an android-arm64 Release build of dotnet new maui --sample-content on an Android 16 arm64 emulator.

Level 3 Level 22
APK size 22,547,511 bytes 21,494,839 bytes
Startup median (30 runs) 1,274.5 ms 1,277.5 ms

The APK decreased by 1,052,672 bytes (4.67%). The 3 ms startup median difference is measurement noise: the bootstrapped 95% confidence interval for the median difference was -14.5 ms to +20.5 ms.

Testing

  • make prepare && make all CONFIGURATION=Debug
  • ./dotnet-local.sh test bin/TestDebug/net10.0/Xamarin.Android.Build.Tests.dll --filter "Name~BuildAssemblyStoreCompressionLevel" β€” 3 passed
  • ./dotnet-local.sh test bin/TestDebug/net10.0/Xamarin.Android.Build.Tests.dll --filter "Name~BuildReleaseArm64" β€” 4 CoreCLR cases passed, 4 unsupported NativeAOT cases skipped
  • published the sample with level 3 explicitly and with the new Release default
  • ran two alternating rounds of 15 measured cold-process launches per APK, with three warmups per round

Use the maximum Zstandard compression level for optimized builds while retaining level 3 for Debug builds and explicit overrides.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: eb86bd2d-705d-488d-8ffb-919527704b87
Copilot AI lite review requested due to automatic review settings August 18, 2026 08:57

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 updates the default Zstandard compression level used for the assembly store in Xamarin.Android builds, increasing compression for optimized (typically Release) builds to reduce APK size while preserving existing defaults and override behavior.

Changes:

  • Set $(_AndroidAssemblyStoreCompressionLevel) default to 22 when $(Optimize) is True.
  • Keep the existing default of 3 for non-optimized builds.
  • Preserve explicit $(_AndroidAssemblyStoreCompressionLevel) overrides by only applying defaults when the property is unset.
Show a summary per file
File Description
src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets Adjusts the default assembly store compression level based on $(Optimize) to improve APK size for optimized builds.

Review details

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

Describe the optimized and non-optimized defaults, override behavior, and compression tradeoffs for XA5304.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: eb86bd2d-705d-488d-8ffb-919527704b87
<AndroidGenerateLayoutBindings Condition=" '$(AndroidGenerateLayoutBindings)' == '' ">False</AndroidGenerateLayoutBindings>
<AndroidFragmentType Condition=" '$(AndroidFragmentType)' == '' ">Android.App.Fragment</AndroidFragmentType>
<AndroidEnableAssemblyCompression Condition=" '$(AndroidEnableAssemblyCompression)' == '' ">True</AndroidEnableAssemblyCompression>
<_AndroidAssemblyStoreCompressionLevel Condition=" '$(_AndroidAssemblyStoreCompressionLevel)' == '' And '$(Optimize)' == 'True' ">22</_AndroidAssemblyStoreCompressionLevel>

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.

Is this defined late enough, you can use $(AndroidIncludeDebugSymbols)?

That property is based off several properties: Optimize, DebugSymbols, DebugType.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It is defined later, so we would need to move this default below the AndroidIncludeDebugSymbols calculation. I think $(Optimize) is the clearer criterion here: changing DebugSymbols or DebugType should not independently change the assembly-store compression level. I am going to keep this tied directly to optimized builds.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6f5bfadf-177c-4959-8df7-04f2c4ca32d2
@jonathanpeppers
jonathanpeppers merged commit 8004b80 into main Aug 19, 2026
44 checks passed
@jonathanpeppers
jonathanpeppers deleted the dev/simonrozsival/zstd-max-release branch August 19, 2026 14:43
@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