[MicroPerf] Fuse the optimizer inlining copy + type-instantiation passes - #20363
Open
T-Gro wants to merge 1 commit into
Open
[MicroPerf] Fuse the optimizer inlining copy + type-instantiation passes#20363T-Gro wants to merge 1 commit into
T-Gro wants to merge 1 commit into
Conversation
Contributor
❗ Release notes requiredYou can open this PR in browser to add release notes: open in github.dev
|
T-Gro
force-pushed
the
t-gro-remark-fuse-spike
branch
from
August 26, 2026 14:29
5eb52d1 to
ed67aaf
Compare
Contributor
|
🔍 Tooling Safety Check — Affects-Compiler-Output
|
When inlining a generic function saturated by its type arguments, the optimizer cloned the whole body twice: copyExpr (clone + fresh vals), then a separate type-application beta reduction to substitute the type args. remapExpr already applies a type instantiation at every type position, so the generic-inline site now carries the instantiation via mkInstRemap in the same copy pass - one traversal, one val-clone - and applies the (already type-instantiated) body with an empty tyarg list. The range-remark stays a separate pass, unchanged. Non-generic inline sites are untouched, and TypedTreeOps.Remapping is unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 69e8646f-b2d9-4852-af5c-5f96dc2d36a3
T-Gro
force-pushed
the
t-gro-remark-fuse-spike
branch
from
August 26, 2026 17:40
ed67aaf to
7679c37
Compare
T-Gro
enabled auto-merge (squash)
August 27, 2026 08:17
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.
Inlining a generic function saturated by its type arguments cloned the body twice:
copyExpr(clone + fresh vals), then a second full traversal insideMakeApplicationAndBetaReduceto substitute the type arguments.remapExpralready applies a type instantiation at every type position, so the generic-inline site now carries the instantiation viamkInstRemapin the same copy pass — one traversal, one val-clone.Allocation
Release
net11.0, 65,880-LOC project,GC.GetTotalAllocatedBytes(true), 3 runs × 4 iters:Diff
One hunk in
Optimizer.fs(+11 / −4).TypedTreeOps.Remapping.*untouched; no newValCopyFlagcase.Verification
EmittedIL+Optimizationssuites (net11.0)PrintFunctionenv failures — identical on base)InlineIfLambda/ struct / byref / SRTP /GenericZero),--optimize+and--optimize- --debug:portable[<ReflectedDefinition>]assemblynewUniquedelta (one clone instead of two); pickled-payload hash unchanged, name is prefix-consumed — cosmetic onlyBranch fires ~6.2k times per compile of the workload, so the fused path is exercised (not dead).