Skip to content

perf: combined-alternation scan for coding_analysis (deferred from #3069 — parity-hazard notes inside) #3073

Closed

Description

@squid-protocol

Tracking issue for the option 2 of #3069 that PR #3070 deliberately deferred, so the deferral rationale isn't lost. Recommendation: do #3072 first and re-measure; only open this if the residuals still matter.

The idea

Instead of N independent pattern.finditer(seg_code) sweeps per segment, merge rules into one alternation (or a small number of grouped automata) with named groups and attribute each match back to its rule — one pass over the text instead of ~40.

Why it was deferred (the hazards, enumerated in #3070)

If it is ever attempted

The only shape worth prototyping is the first-pass candidate finder: one combined regex of simplified per-rule signatures (no groups, no backtracking constructs) that yields (position, rule) candidates, with every candidate re-verified by the original compiled rule anchored at that position (pattern.match(seg_code, pos) is NOT equivalent to finditer — the verification step needs careful windowing). Exact-match-set parity must be proven with the same corpus-wide A/B harness as #3070 (tests/tools/gate_parity_audit.py pattern) before any golden-master run.

Refs: #3069 (the structural analysis), #3070 (the shipped prefilter + evidence), #3072 (the recommended next lever).

🤖 Generated with Claude Code

Activity

  1. added
    enhancement
    on Sep 16, 2026
  2. squid-protocol commented on Sep 19, 2026

    @squid-protocol
    OwnerAuthor

    Fleet payoff: lower than a single-rule fix — the cost isn't N-pass overhead

    Combined-alternation targets the per-segment N-pass overhead (~40 finditer sweeps → one). But the full-fleet data shows rule CPU is dominated by a few pathological single rules, not the breadth of passes: B_Braces = 53% of rule CPU (3,931s); top 5 of 662 rules = 50%. roslyn's csharp::B_Braces alone is 1,971s. Merging 40 cheap passes into one wouldn't touch that — the win is fixing/gating the hot rule, not reducing pass count.

    Combined with this issue's substantial parity hazards (the 100-group limit, scoped-flag rewrites, load-bearing per-rule Match objects, alternation-order span drift), the risk/reward is poor relative to #3182's targeted work.

    Recommendation: keep deferred as the tracking record. Reassess only if, after the hot Cartography modes are fixed under #3182, the residual many-small-rules overhead is still measurable.

  3. added
    deferred
    on Sep 19, 2026
  4. added
    scope:infra
    on Oct 16, 2026
  5. added 2 commits that reference this issue on Oct 17, 2026
  6. added
    needs:corpus
    on Oct 18, 2026
  7. added a commit that references this issue on Oct 23, 2026
  8. squid-protocol commented on Oct 24, 2026

    @squid-protocol
    OwnerAuthor

    Churn run 3073-20261024T0230Z (host nyx) ended without a PR. No PR: re-measured on main 3548042, combined candidate finder 16.33s vs per-rule literal gate 1.73s (~9.4x), residual sweeps unchanged (#6125 harness, --time). Combined-alternation scan not worth building; recommend owner close #3073 as deferred/not planned, or reopen only with a fleet-scale phase_ab.py run.

  9. squid-protocol commented on Oct 24, 2026

    @squid-protocol
    OwnerAuthor

    Churn run 3073-20261024T0308Z (host melek) ended without a PR. No PR; measurement shows combined finder 9.4x slower; recommend deferring #3073 (hot-rule work in #3182). Owner/close decision left on issue.

  10. squid-protocol commented on Oct 24, 2026

    @squid-protocol
    OwnerAuthor

    Claimed by promoter-bot host melek, lease renewed 2026-10-24T17:20Z. It lapses after 6 h without a renewal. To take it back, assign someone or remove the claim:melek label.

  11. added a commit that references this issue on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claim:melekdeferredenhancementneeds:corpusperformancescope:infra

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions