[MicroPerf] Four profiler-guided hot-path wins from self-build tracing - #20348
Merged
Conversation
Four independent, output-identical hot-path optimizations found by profiling the compiler compiling itself. Emitted IL/metadata is byte-for-byte unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 17e33363-3dfc-4cf9-9c44-a64686bd5ad1
Contributor
|
Co-authored-by: Brian Rourke Boll <brianrourkeboll@users.noreply.github.com>
T-Gro
enabled auto-merge (squash)
August 26, 2026 09:18
abonie
approved these changes
Aug 28, 2026
This was referenced Aug 28, 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.
Four independent, output-identical hot-path optimizations found by profiling the compiler compiling itself (dotnet-trace sampled thread-time plus targeted microbenchmarks). Emitted IL and metadata are byte-for-byte unchanged on every workload checked.
array → list → List.sortWith → arrayround-trip with a packedint64key[Val:32][Tag:8][pos:24]sorted byArray.Sortand gathered. Isolated microbench: 4–8× faster, ~6× less allocation (65,536 rows: 10.6 ms → 2.5 ms, 6.55 MB → 1.05 MB; 64 rows: 2.99 µs → 0.43 µs).IntMap; it is now folded out directly. That sort's projection was the second-hottest managed method in the self-build trace at 4.09 s; isolated, the rewrite is 2.6–7× faster at ~half the allocation.addNullnessToTynow returns the originalTTypewhen combining nullness leaves it unchanged, instead of rebuilding a structurally identical node. ~153,000 redundantTTypeallocations removed per 65k-LOC compile (~5 MB), and the function's own CPU drops 27% (0.52 s → 0.38 s).tryTcrefOfAppTyout of the per-iteration guards (common-subexpression elimination), cutting ~25% off the loop's exclusive CPU in the self-build trace (214 ms → 160 ms).