Skip to content

[MicroPerf] Make List.vMapFold inline to drop the nullness-import closure - #20415

Open
T-Gro wants to merge 1 commit into
mainfrom
t-gro-vmapfold-inline
Open

[MicroPerf] Make List.vMapFold inline to drop the nullness-import closure#20415
T-Gro wants to merge 1 commit into
mainfrom
t-gro-vmapfold-inline

Conversation

@T-Gro

@T-Gro T-Gro commented Sep 1, 2026

Copy link
Copy Markdown
Member

List.vMapFold's only caller (ImportILTypeWithNullness) passes a lambda, so making the combinator inline + [<InlineIfLambda>] beta-reduces that lambda into the call site and no closure is allocated per imported IL generic argument. No call-site change.

Sampled closure allocation (gc-verbose, fsc self-compiling src/Compiler on the net11 perf bundle):

closure (call site) before after
ImportILTypeWithNullness@359 (via List.vMapFold) 62.1 MB 0

Deterministic proof: the ImportILTypeWithNullness@359 closure class is present in FSharp.Compiler.Service.dll on main and absent after this change. Cost is +512 bytes of IL (+0.0024%). Behavior is unchanged — result order, state threading, and the empty / singleton / multi-element cases are byte-identical, and the inner let rec go compiles to a while loop (verified stack-safe on a 5M-element list).

vMapFold's only caller (ImportILTypeWithNullness in import.fs) passes a
lambda; making the combinator inline + InlineIfLambda folds that lambda so
no per-call closure is allocated per imported IL type.

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 September 1, 2026 14:39
@T-Gro T-Gro added the NO_RELEASE_NOTES Label for pull requests which signals, that user opted-out of providing release notes label Sep 1, 2026
@T-Gro
T-Gro requested a review from abonie September 1, 2026 14:39
@T-Gro
T-Gro enabled auto-merge (squash) September 1, 2026 14:39
@github-actions

github-actions Bot commented Sep 1, 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

@github-actions github-actions Bot added the AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed label Sep 1, 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

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

1 participant