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 shapes: build the node map inside Shape.CopyTo's copy pass (no isolated measurement) #592
Shape.CopyTo copies the nodes of a range, then builds the source-to-copy node map in a second pass with Zip and ToDictionary, so that annotations can be remapped. The source and destination nodes are already visited in matching order during cloning, so the loop can record the mapping as it goes. The change allocates the map on the first node of a nonempty range and fills it in the copy pass, and skips the map for an empty range. It removes one enumeration and one LINQ dictionary from each annotated shape copy. The change is on the archived branch perf/hc-optimization-archive.
Measured. Nothing in isolation. It was timed only together with shape copy-on-write and the feature-structure clone work, so no standalone ratio is claimed.
What a revival must do first. Measure it alone, in allocations per shape copy. Keep ShapeCopyToTests (empty ranges, leaf and spanning annotations, remapping, independence of the copy).
Archived from docs/hc-optimization-ledger @ 2eba2f5 (docs/optimizations/shape-copy-single-pass-map.md), which is being deleted:
Build Shape.CopyTo's node map in the copy pass
Status: retained on perf/hc-optimization-archive, not merged (Shape.CopyTo). Portable: yes, when a port has the same node-remapping requirement.
Invariant
Annotations refer to nodes in the source shape and must be remapped to the corresponding nodes in the copy.
The source and destination nodes are already visited in matching order while cloning, so that loop can record
the mapping directly. No second Zip/ToDictionary traversal is required. An empty source range needs no
map; every nonempty range builds one because annotations are queried only after nodes have been copied.
Implementation
Shape.CopyTo allocates the map on the first node of a nonempty range and fills it as each node is cloned.
Annotation ranges are then copied through that map exactly as before.
Evidence
The change removes one enumeration and one LINQ-built dictionary from each annotated shape copy. It was not
timed independently from shape copy-on-write and feature-structure clone work, so no standalone ratio is
claimed.
Correctness coverage and limits
ShapeCopyToTests covers empty ranges, leaf and spanning annotations, node/range remapping, and independence
of the copy.
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/shape-copy-single-pass-map.md), which is being deleted:Build
Shape.CopyTo's node map in the copy passStatus: retained on
perf/hc-optimization-archive, not merged (Shape.CopyTo).Portable: yes, when a port has the same node-remapping requirement.
Invariant
Annotations refer to nodes in the source shape and must be remapped to the corresponding nodes in the copy.
The source and destination nodes are already visited in matching order while cloning, so that loop can record
the mapping directly. No second
Zip/ToDictionarytraversal is required. An empty source range needs nomap; every nonempty range builds one because annotations are queried only after nodes have been copied.
Implementation
Shape.CopyToallocates the map on the first node of a nonempty range and fills it as each node is cloned.Annotation ranges are then copied through that map exactly as before.
Evidence
The change removes one enumeration and one LINQ-built dictionary from each annotated shape copy. It was not
timed independently from shape copy-on-write and feature-structure clone work, so no standalone ratio is
claimed.
Correctness coverage and limits
ShapeCopyToTestscovers empty ranges, leaf and spanning annotations, node/range remapping, and independenceof the copy.
The complete conformance-inclusive run passed 603 tests with one expected host-privilege skip.