Skip to content

[MicroPerf] Four profiler-guided hot-path wins from self-build tracing - #20348

Merged
T-Gro merged 4 commits into
mainfrom
t-gro-net11-compiler-perf-research
Aug 28, 2026
Merged

[MicroPerf] Four profiler-guided hot-path wins from self-build tracing#20348
T-Gro merged 4 commits into
mainfrom
t-gro-net11-compiler-perf-research

Conversation

@T-Gro

@T-Gro T-Gro commented Aug 25, 2026

Copy link
Copy Markdown
Member

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.

  • Metadata table sort: replaced the array → list → List.sortWith → array round-trip with a packed int64 key [Val:32][Tag:8][pos:24] sorted by Array.Sort and 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).
  • Decision-tree target emit: the postponed-target set was re-sorted by index although it already arrives ordered from an 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.
  • Nullness application: addNullnessToTy now returns the original TType when combining nullness leaves it unchanged, instead of rebuilding a structurally identical node. ~153,000 redundant TType allocations removed per 65k-LOC compile (~5 MB), and the function's own CPU drops 27% (0.52 s → 0.38 s).
  • Type-hierarchy walk: hoisted the repeated tryTcrefOfAppTy out 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).

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
@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

⚠️ Release notes required, but author opted out

Warning

Author opted out of release notes, check is disabled for this pull request.
cc @dotnet/fsharp-team-msft

@T-Gro T-Gro added the NO_RELEASE_NOTES Label for pull requests which signals, that user opted-out of providing release notes label Aug 25, 2026
@github-actions github-actions Bot added the AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed label Aug 25, 2026
Comment thread src/Compiler/AbstractIL/ilwrite.fs Outdated
@T-Gro
T-Gro requested a review from abonie August 26, 2026 09:17
@T-Gro
T-Gro enabled auto-merge (squash) August 26, 2026 09:18
@T-Gro T-Gro changed the title Perf microwins - via self-build hot paths [MicroPerf] Four profiler-guided hot-path wins from self-build tracing Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed NO_RELEASE_NOTES Label for pull requests which signals, that user opted-out of providing release notes Theme-Performance

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants