Skip to content

[MicroPerf] Inline TryD to remove constraint-solver closure allocations - #20367

Open
T-Gro wants to merge 3 commits into
mainfrom
t-gro-combinator-closure-inline
Open

[MicroPerf] Inline TryD to remove constraint-solver closure allocations#20367
T-Gro wants to merge 3 commits into
mainfrom
t-gro-combinator-closure-inline

Conversation

@T-Gro

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

Copy link
Copy Markdown
Member

TryD is now inline with [<InlineIfLambda>] on its always-run f, so the argument closures are no longer allocated at the constraint-solver call sites; IgnoreFailedMemberConstraintResolution is inline so its forwarded f1 stays a literal.

Sampled GC closure allocation at the hottest site (SolveTypeEqualsType via SolveTypeEqualsTypeKeepAbbrevsWithCxsln), compiling a 120-file set — ~412 MB removed:

closure before after
f lambda (@1514) 240 MB 0
g lambda (@1515) 172 MB 0

Cost is negligible: FSharp.Compiler.Service.dll grows +1.5 KB (+0.007%) from the inlined expansions. Pure inline refactor — --deterministic+ self-compile is byte-identical (SHA-256 match), no behavior change.

Zset.iter/Zmap.iter were evaluated and left unchanged — they only pass the lambda to a non-inline recursive tree-walker, so [<InlineIfLambda>] cannot remove the closure.

Make `TryD` inline with `[<InlineIfLambda>]` on the always-evaluated `f`
argument so the `f`/`g` lambda closures are no longer allocated at each
call site (hottest: SolveTypeEqualsType via SolveTypeEqualsTypeKeepAbbrevsWithCxsln).
`IgnoreFailedMemberConstraintResolution` is made inline so its non-literal
`f1` propagates as a lambda, keeping InlineIfLambda satisfied without FS3517.

Pure inline refactor: byte-identical compiler output (deterministic self-compile
SHA-256 match); no behavior change.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@T-Gro
T-Gro requested a review from a team as a code owner August 26, 2026 15:24
@T-Gro
T-Gro requested a review from abonie August 26, 2026 15:24
@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 26, 2026
@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

❗ Release notes required

You can open this PR in browser to add release notes: open in github.dev


✅ Found changes and release notes in following paths:

Change path Release notes path Description
`src/Compiler` docs/release-notes/.FSharp.Compiler.Service/11.0.100.md

@github-actions github-actions Bot added the AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed label Aug 26, 2026
@T-Gro T-Gro changed the title Inline TryD to remove constraint-solver closure allocations [MicroPerf] Inline TryD to remove constraint-solver closure allocations Aug 27, 2026
@T-Gro
T-Gro enabled auto-merge (squash) August 27, 2026 08:20
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@T-Gro T-Gro removed NO_RELEASE_NOTES Label for pull requests which signals, that user opted-out of providing release notes AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed labels Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

1 participant