Repository navigation
Description
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)
- Flag mixes: rules within one language differ in re.I/re.M/re.S; merging requires scoped
(?i:…)rewrites of every branch, each a parity risk. - The 100-group limit: group-heavy rules (TS
argsalone has ~10 groups) blow the combined pattern's group budget fast; renumbering breaks theclass_startlineage extractor (group 1/group 2 semantics, THE LINEAGE EXTRACTOR treats any class_start group 2 as an inheritance parent, even when group 1/2 are alternation-exclusive (not name+parent) #1983) and the COBOLargsoperand counter (m.group(1) if m.lastindex else m.group(0)). - Per-rule Match objects are load-bearing:
_scope_filters/_apply_scope_filter, the COBOL override, andclass_startparent extraction all consume real per-rule Match objects with the original group numbering. - Alternation-order semantics: Python's leftmost-alternative-wins means a combined pattern can return a different match span than the standalone rule at the same position — silent count drift that golden masters would catch only where the corpus happens to exercise it.
- Marginal win shrinks post-perf(detector): required-literal prefilter for the shared coding_analysis rule pass #3070: with 62% of sweeps already gated away (and perf: per-line gating for the line-anchored rules the literal prefilter can't touch #3072 targeting the expensive anchored remainder), the combined scan could only act as a second-level prefilter — find candidate positions cheaply, then confirm with the real rule — which is where most of its theoretical win goes.
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
squid-protocol commentedon Sep 19, 2026
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
finditersweeps → 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'scsharp::B_Bracesalone 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.
docs(perf): #3073 reassessment datapoint, combined-alternation scan s…
perf(tools): combined-alternation candidate-finder parity harness (Pa…
perf(tools): time the #3073 candidate finder against the gate it woul…
squid-protocol commentedon Oct 24, 2026
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.squid-protocol commentedon Oct 24, 2026
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.squid-protocol commentedon Oct 24, 2026
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 theclaim:meleklabel.docs(perf): record the #3073 re-measurement on main 3548042 (Part of #…