You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
HermitCrab feature structures: skip the clone map for frozen flat trees (no isolated measurement) #587
FeatureStruct.Clone builds an old-to-new copies map on every clone. A frozen structure marked as a flat tree has no aliases or cycles below its root, so a top-level clone cannot meet the same value twice and needs no map. The change skips the map in that case. Other clones borrow a per-thread map, clear it in finally, and use a fresh map when reentered. The internal recursive constructor always uses the caller's map. This is a per-thread pooled collection, not a cross-parse cache. The change is on the archived branch perf/hc-optimization-archive.
Measured. Nothing in isolation. It was timed only as part of the package, so the record makes no speed claim.
What a revival must do first. Measure it alone, in allocations or dictionary operations avoided per clone. Keep FeatureStructCloneTests (aliases, cycles, reentrancy, a tree embedded in a shared graph) with it.
Archived from docs/hc-optimization-ledger @ 2eba2f5 (docs/optimizations/feature-struct-frozen-tree-clone.md), which is being deleted:
Reuse or skip the feature-structure clone map
Status: retained on perf/hc-optimization-archive, not merged (FeatureStruct.Clone). Portable: yes; the specific pool is .NET-oriented, while the tree proof is general.
Invariant
A frozen structure marked as a flat tree has no aliases or cycles to preserve below its root. Its top-level
clone therefore cannot encounter the same value twice, so the old-to-new copies map has no semantic work to
do. Recursive cloning inside another graph must still use the caller's map even when the child itself looks
tree-shaped, because the parent graph may refer to that child elsewhere.
Implementation
A top-level clone skips the map for a proven frozen flat tree. General clones borrow a per-thread map, clear
it in finally, and fall back to an independent map for reentrant calls. The internal recursive constructor
always honors the caller-provided map.
Evidence
This removes dictionary creation and lookup from the common clone case. It travelled with the broader clone
allocation work and was not timed independently, so the record deliberately makes no isolated speed claim.
Correctness coverage and limits
FeatureStructCloneTests covers alias preservation, cycles, reentrant cloning, and the distinction between a
top-level tree and a tree embedded in a shared graph. The complete conformance-inclusive run passed 603 tests
with one expected host-privilege skip.
Activity
johnml1135 commentedon Nov 7, 2026
Archived from
docs/hc-optimization-ledger@ 2eba2f5 (docs/optimizations/feature-struct-frozen-tree-clone.md), which is being deleted:Reuse or skip the feature-structure clone map
Status: retained on
perf/hc-optimization-archive, not merged (FeatureStruct.Clone).Portable: yes; the specific pool is .NET-oriented, while the tree proof is general.
Invariant
A frozen structure marked as a flat tree has no aliases or cycles to preserve below its root. Its top-level
clone therefore cannot encounter the same value twice, so the old-to-new copies map has no semantic work to
do. Recursive cloning inside another graph must still use the caller's map even when the child itself looks
tree-shaped, because the parent graph may refer to that child elsewhere.
Implementation
A top-level clone skips the map for a proven frozen flat tree. General clones borrow a per-thread map, clear
it in
finally, and fall back to an independent map for reentrant calls. The internal recursive constructoralways honors the caller-provided map.
Evidence
This removes dictionary creation and lookup from the common clone case. It travelled with the broader clone
allocation work and was not timed independently, so the record deliberately makes no isolated speed claim.
Correctness coverage and limits
FeatureStructCloneTestscovers alias preservation, cycles, reentrant cloning, and the distinction between atop-level tree and a tree embedded in a shared graph. The complete conformance-inclusive run passed 603 tests
with one expected host-privilege skip.