Skip to content

HermitCrab analysis: port the edge-segment prefilter (time-only, 0 steps) #564

Open

Description

@johnml1135

Port ledger row 22's edge-segment prefilter to master, only if the owner wants a time-only gain. HermitCrab analysis spends 70-91% of its events on attempts that do not unapply; each attempt runs a full FST traversal even when the word's edge segment cannot match. The prefilter makes each attempt cheaper but removes no step, so under the owner's step metric its value is 0.

Problem (steps and cost)

Census: not-unapplied attempts are 70-91% of analysis events. Ledger row 7 ("count is not cost") and row 30 (time-only work is outside the owner's metric) apply. The archived record (origin/perf/hc-optimization-archive, docs/optimizations/edge-segment-prefilter.md) measured parity on 45 Sena words and 464 conformance words, FST traversals -87% and arc checks -54%, trace events unchanged. Steps saved: 0%. Arc checks and traversals are different units and are not steps.

Proposed change

Re-apply the archived prefilter to current master in AnalysisAffixProcessRule (check the first or last segment of the word against the literal edge of the affix pattern before running the traversal). No behaviour change; no new parses.

Soundness

Argued in the archive record; it was sound on the parity sets above. Must be re-argued against current master and against #561 or #562 if they land, since they touch the same rules.

Memory bound

Per-rule edge segment sets sized to the grammar, bytes to KB. No cache.

Expected value (low)

0% in steps by definition. Worth doing only as a wall-time improvement and only if the owner decides time-only work is acceptable. This issue is filed so that decision is recorded, not as a recommendation.

Measurement plan

Same-binary A/B on the 45 Sena words and the conformance suite: verdicts and trace events identical, report traversals and arc checks beside a step count that must not change.

Kill criterion

Close if the owner rules time-only work out of scope (ledger row 30), or if any trace event or parse differs.

Dependencies

None. Interacts with #561 in that it removes whole partial subtrees before their attempts run, which reduces the attempts this prefilter would make cheaper.

Related

🤖 Generated with Claude Code

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