Skip to content

HermitCrab FST: deduplicate traversal instances by (State, AnnotationIndex) (rejected in general form: 112 of 20,000 fuzz cases differ) #594

Closed as not planned

Description

@johnml1135

Proposed in #511. Inside Traverse, skip a new traversal instance whose (State, AnnotationIndex) was already pushed, on the grounds that only registers differ. TraversalMethodBase.Advance forks an instance per Optional annotation, so instance count grows exponentially in optional annotations, and the skip bounds it at N * |States|. A 2-state FSA popped 2,097,150 instances at 20 optional annotations.

Measured. A differential fuzz of 20,000 random pattern/input pairs found 112 cases where Match() differs from production: 108 from variable bindings and 4 from capture registers that shorten the range. AllMatches().First() was identical in all 20,000. Gated on the deterministic method and no capture groups, divergences fell 112 to 0. Environment matchers are 0.20% (Amharic) and 1.18% (Mbugwe) of instances. In the analysis rules, 93.95% of Amharic pushes look collapsible, but 99.7% have differing registers, so only 0.28% to 4.11% of collapses are free.

Why rejected. The key omits variable bindings and registers, which AllSubmatches callers read. The sound narrowed form (deterministic, no capture groups) needs no more evidence, but it was not shipped. It is not a cache and adds no memory.

Record: https://github.com/sillsdev/machine/blob/2eba2f502338705a4d529d7034cecb6303db7f35/docs/rejected-optimizations/state-position-traversal-dedup.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

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions