Repository navigation
Optimize the NativeAOT CLI for size - #55733
Merged
Merged
Conversation
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 44897815-78b2-4f83-a245-912dfc79eb74
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
Sets the NativeAOT build for the dotnet-aot CLI project to prefer size optimizations, aiming to reduce the produced native binary size at the cost of a small, mostly fixed startup overhead.
Changes:
- Set
OptimizationPreference=Sizeinsrc/Cli/dotnet-aot/dotnet-aot.csprojto bias NativeAOT compilation toward smaller output.
JeremyKuhne
approved these changes
Aug 12, 2026
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
Set
OptimizationPreference=Sizefor the NativeAOT CLI.This setting reduces the NativeAOT binary size in exchange for a small, mostly fixed startup cost.
Benchmark results
The measurements used Release builds for
win-x64on dotnet/sdk PR #55497. The full benchmark report contains the setup and caveats.Binary size
Invariant globalization reduced the PR-head binary by only 0.22–0.25 MiB, or approximately 0.6%. This PR does not change globalization behavior.
Most PR growth was native code and read-only data.
.rdatacontributed 13.09 MiB, and.textcontributed 9.60 MiB.Startup time
Each result is the median of 150 launches on the PR head.
--version--info--helpbuild --helprestore --helpsdk checkSize optimization added approximately 9–13 ms with normal globalization. The fixed cost creates a larger percentage change for commands that do little work.
Validation
Published
src/Cli/dotnet-aot/dotnet-aot.csprojfor Release andwin-x64. The NativeAOT compiler evaluatedOptimizationPreference=Sizeand produced the native library.