[MicroPerf] Remove per-call closure allocations in post-inference checks - #20447
Open
T-Gro wants to merge 1 commit into
Open
[MicroPerf] Remove per-call closure allocations in post-inference checks#20447T-Gro wants to merge 1 commit into
T-Gro wants to merge 1 commit into
Conversation
Contributor
|
T-Gro
pushed a commit
that referenced
this pull request
Sep 4, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kerams
reviewed
Sep 4, 2026
T-Gro
force-pushed
the
t-gro-checktypedeep-structvisitor-spike
branch
2 times, most recently
from
September 4, 2026 12:15
85bdcf9 to
9f8be6f
Compare
T-Gro
force-pushed
the
t-gro-checktypedeep-structvisitor-spike
branch
3 times, most recently
from
September 7, 2026 12:09
4e9f682 to
bf9b4ae
Compare
CheckTypeDeep threaded a tuple of five optional closures through its mutual recursion, so it allocated those closures, the tuple, the option wrappers, and a per-node TypeInstCtx heap value for every checked type. It is now generic over a struct visitor (ITypeVisitor), TypeInstCtx is a struct, and the onInnerByrefError callback is a ByrefError union. The walk allocates nothing and diagnostics are unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1696d169-c464-47bd-85ae-efef96c10d62
T-Gro
force-pushed
the
t-gro-checktypedeep-structvisitor-spike
branch
from
September 7, 2026 12:51
bf9b4ae to
7fa95f6
Compare
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.
CheckTypeDeep, the type walker used by the post-inference checks, threaded a tuple of five optional closures through its mutual recursion, so it allocated those closures, the tuple, the option wrappers, and a per-nodeTypeInstCtxheap value for every checked type. It is now generic over a struct visitor,TypeInstCtxis a struct, and the inner-byref-error callback is a data-carrying union. The walk allocates nothing and diagnostics are unchanged.Sampled allocation removed (gc-verbose
GCAllocationTick), by self-compilation input:Compiler-generated closure types no longer emitted into
FSharp.Compiler.Service.dll(verified by metadata scan of the built assembly):visitTyconRef@670visitAppTy@697visitAppTy@713-1visitTraitSolution@716visitTyar@663CheckType@733CheckValSpec@2068CheckTypeDeep@401CheckTypeAux@730CheckTraitInfoDeep@459CheckForByrefLikeType@466CheckForByrefLikeType@466-1CheckForByrefType@470CheckForByrefType@470-1visitType@534-1visitType@548-2visitType@699-3TypeInstCtxis now a struct, so itsIlGenericInst/TyparInstheap allocations are gone as well.