[MicroPerf] Reverse instead of sort already-ordered branch fixups in IL writer - #20349
Merged
Conversation
Contributor
|
T-Gro
marked this pull request as draft
August 26, 2026 08:03
origReqdBrFixups is recorded by prepending at strictly-increasing code positions, so it always arrives strictly descending by fixupLoc with no ties. The stable List.sortBy is therefore exactly List.rev. Output is byte-for-byte identical. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
T-Gro
force-pushed
the
t-gro-perf-applybrfixups-sort
branch
from
August 26, 2026 08:10
e87474e to
b0770fe
Compare
T-Gro
marked this pull request as ready for review
August 26, 2026 08:24
T-Gro
marked this pull request as draft
August 26, 2026 08:44
T-Gro
marked this pull request as ready for review
August 26, 2026 08:44
T-Gro
enabled auto-merge (squash)
August 26, 2026 08:44
abonie
reviewed
Aug 28, 2026
abonie
approved these changes
Aug 28, 2026
…dBrFixups Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
abonie
approved these changes
Sep 4, 2026
T-Gro
disabled auto-merge
September 9, 2026 12:47
This was referenced Sep 9, 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.
Output-identical: emitted IL and metadata are byte-for-byte unchanged on every workload checked.
applyBrFixupsstable-sorted the required branch fixups by code offset once per emitted method body. Fixups are recorded by prepending at the current code position as the stream is emitted linearly, so the list always arrives strictly descending by offset with no ties — the sort is exactly a reverse. ReplacedList.sortBywithList.rev.Measured over a 65,880-LOC / 120-file compile (net11 Release; ~46,465 calls/compile, 88% empty lists, longest 25): 0.595 ms → 0.240 ms and 1444 KB → 634 KB allocated per compile for this step. Isolated microbench on the same call-length distribution is ~3× faster at ~2.3× less allocation, and beats a packed-
int64Array.Sortand every other candidate tried.Equivalence was checked by computing both orderings for every emitted method during a full compile and comparing element-for-element: 139,370 method bodies, 0 mismatches (and every list confirmed strictly descending, 0 ties).