Repository navigation
Use server GC and turn off dynamic PGO in released binaries - #93
Merged
Merged
Conversation
A build is a short, CPU bound, allocation heavy run. On a 2650 source project (18 cores) cold build went from ~27 s to ~22 s, build with source cache from ~20 s to ~17 s, for ~170 MB more memory. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Bobris
approved these changes
Oct 29, 2026
Bobris
left a comment
Contributor
There was a problem hiding this comment.
Reviewed the runtime configuration and changelog. No blocking findings. CI is green on Linux, Windows and macOS. Independently published the trimmed, self-contained ReadyToRun osx-arm64 executable, verified System.GC.Server=true and System.Runtime.TieredPGO=false in its generated runtimeconfig, and successfully built TestProjects/BbApp without the build cache with DOTNET_PROCESSOR_COUNT=2. The documented memory/startup tradeoff is acceptable.
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.
Problem
A build is a short (tens of seconds), CPU bound, allocation heavy process, but the released binary runs with the default settings: workstation GC and dynamic PGO. Sampling a cold build of a large project (
dotnet-trace, sampled thread time) shows the single threaded bundler and the crawl thread spending seconds suspended for GC (Thread.PollGC~4.6 s in the bundler, ~2 s in the crawl), and with ReadyToRun code the instrumented tier-0 recompilation of hot methods does not pay off in such a short run.Change
bb/bb.csprojaddsSystem.GC.Server=trueandTieredPGO=falseto the runtime config. (<ServerGarbageCollector>alone did not end up inbb.runtimeconfig.jsonof the trimmed, self-contained publish here, so it is set as aRuntimeHostConfigurationOption.)Results
phoenix
nsi-bobwai(2650 sources, tsrs), Windows, 18 logical cores, 63 GB, ReadyToRun publish of 7.1.0 with and without this change, alternating runs:bb b --nocachebb bwith build cachebb --versionEach setting alone (env
DOTNET_gcServer=1/DOTNET_TieredPGO=0on the stock 7.0.6 and 7.1.0 binaries) helps as well: roughly -3 to -6 s for server GC and -2 to -3 s for PGO off, with some noise, so I kept both.Output is not affected (runtime settings only).
DOTNET_gcServer=0andDOTNET_TieredPGO=1restore the previous behavior.Please review
System.GC.HeapCount(andGCHeapAffinitizeMask) is an option if memory is a concern.bbalso runs as a long lived dev server (watch mode); I did not measure memory there.System.GC.ConserveMemorycould be added if server GC keeps too much.🤖 Generated with Claude Code