[MicroPerf] Reduce Detuple usage-analysis allocation with a mutable Dictionary - #20351
Merged
Conversation
Contributor
|
T-Gro
marked this pull request as draft
August 26, 2026 08:02
T-Gro
force-pushed
the
t-gro-maptree-alloc-spike
branch
2 times, most recently
from
August 26, 2026 08:38
9552876 to
605b9b2
Compare
Detuple.GlobalUsageAnalysis threads a Uses map (Zmap<Val,_>) through a per-file fold; logUse does tryFind+add on every value occurrence, so a value used K times re-inserts at the same key K times, each path-copying the whole balanced tree. This is the largest MapTree.mk allocation source in the optimizer. A per-file mutable Dictionary (BagAdd) removes the churn; Uses is only grown during the sequential per-file fold and read back by point lookup or one enumeration sorted by (valSourceOrderKey, Stamp), so its iteration order never reaches output. 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-maptree-alloc-spike
branch
from
August 26, 2026 09:07
605b9b2 to
ce9ed28
Compare
T-Gro
marked this pull request as ready for review
August 26, 2026 09:13
T-Gro
enabled auto-merge (squash)
August 27, 2026 08:20
abonie
approved these changes
Aug 28, 2026
This was referenced Aug 29, 2026
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.
Detuple
GlobalUsageAnalysis.Uses:Zmap<Val,_>→ per-file mutableDictionary.logUsere-adds the same key on every occurrence; each add path-copied the whole AVL tree before.65k-LOC compile, net11.0 Release:
MapTreeNode<Val, _ list>(this map): 634 MB → 0