Conversation
The two inlining hot paths in the optimizer ran copyExpr (a full tree rebuild that clones locals) and then remarkExpr (a second full tree rebuild that only rewrites every node's range to the call site). The first tree is discarded immediately, so the second rebuild is pure waste. remapExprImpl now carries an optional target range; when set it re-marks every constructed node in the same traversal it already does for copying, reproducing remarkExpr's behaviour exactly (range rewrite, debug-point erasure on loop/try TOps, NoneAtInvisible matches, NoneAtSticky binds, DebugPoint wrapper stripping, and preserving introduced temporaries' original ranges). CopyExprForInlining and the ConstExprValue path use the new copyAndRemarkExpr entry point instead of copyExpr |> remarkExpr. Output is byte-for-byte identical (IL and PDB) to before on every workload checked, and a 65,880-LOC / 120-file compile drops ~321 MB of allocation per compile (10,673 MB -> 10,352 MB/iter, --optimize+). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
|
Member
Author
|
Closing — change is too bloated for the win; reworking toward a minimal diff. |
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.
The optimizer's two inlining paths ran
copyExpr(a full tree rebuild that clones locals) thenremarkExpr(a second full rebuild that only stamps every node's range with the call site), discarding the first tree — so the second rebuild was pure allocation.remapExprImplnow takes an optional target range and re-marks in the same traversal it already does for copying, reproducingremarkExprexactly (range rewrite, debug-point erasure on loop/try ops,NoneAtInvisiblematches,NoneAtStickybinds,DebugPointstripping, and keeping introduced temporaries' original ranges).Emitted IL and PDBs are byte-for-byte unchanged on every workload checked. A 65,880-LOC / 120-file compile allocates ~321 MB less per compile (10,673 → 10,352 MB/iter,
--optimize+).