Skip to content

HermitCrab shapes: build the node map inside Shape.CopyTo's copy pass (no isolated measurement) #592

Open

Description

@johnml1135

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).

Record: https://github.com/sillsdev/machine/blob/2eba2f502338705a4d529d7034cecb6303db7f35/docs/optimizations/shape-copy-single-pass-map.md
Ledger: https://github.com/sillsdev/machine/blob/2eba2f502338705a4d529d7034cecb6303db7f35/docs/hermitcrab-optimization-ledger.md; disposition: https://github.com/sillsdev/machine/blob/2eba2f502338705a4d529d7034cecb6303db7f35/docs/hermitcrab-perf-2026-09-disposition.md
From #490 (closed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status
      🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions