Skip to content

HermitCrab engine: share frozen syntactic feature structures on internal Word clones (about 15% of a heavy Sena profile, never isolated) #595

Open

Description

@johnml1135

Internal clones of a frozen Word deep-copy its SyntacticFeatureStruct, then freeze and hash it again when building analysis keys. The change adds Word.CloneForEngine, which shares the frozen structure until a rule must mutate it. The three in-place analysis mutation sites call EnsureOwnSyntacticFeatureStruct first. A per-Morpher setting (HC_SHARE_SYNTACTIC_FS=false opts out) controls sharing. Public Word.Clone() stays a deep, mutable clone. This is sharing, not a cache. CloneForEngine and EnsureOwnSyntacticFeatureStruct are on the archived branch only.

Measured. The heaviest Sena profile attributed roughly 15% of CPU to freezing and hashing a newly cloned syntactic feature structure while building analysis keys. The five-language measurement is branch-wide, so no standalone speedup is assigned. The wall-clock figure is a profile share and is not attributed.

What a revival must do first. Time it with the toggle alone, in clones and freezes avoided. Do not use the old morph-count signature for parity. Sharing is unavailable for mutable source words.

Record: https://github.com/sillsdev/machine/blob/2eba2f502338705a4d529d7034cecb6303db7f35/docs/optimizations/syntactic-feature-structure-sharing.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