You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#3175 (largest-first worker dispatch, PR #3181) shipped output-safe but wall-flat — scheduling was never the bottleneck. A full profiled scan of all_language_repo (16.53s wall, 1.22M LOC, 73.8k LOC/s) located the real limiters. This issue covers limiter #1: the Optical Detector regex phase. Sibling: the single-threaded tail (see companion issue).
Cumulative per-worker CPU by extraction phase (÷~16 cores):
Optical Detector is 55% of all per-file work — 2× the already-gated Security Lens. And it's composition-driven, not size-driven: 26.5 ms/file on ALR vs ~10.6 ms/file on curl, because ALR contains COBOL. The --splicing-speed tail is unambiguous:
2.68s cobol::Cartography_Mode_A_Labels ← single most expensive regex in the whole scan
1.60s cobol::func_start
1.44s typescript::Cartography_Mode_B_Braces
0.78s cobol::safety
0.66s cobol::fragile_debt
... 7 of the top ~15 modes are cobol::
Goal
Bring Optical Detector cumulative CPU down the way #3069 / #3072 / #3173 brought down Security Lens, starting with the hottest modes.
Seam / files
gitgalaxy/core/detector.py — splice() (~L1396) runs the modes; the cache-fill deriving (rule_name, pattern, mapped_key, gate, line_gate) (~L2653) is where gates attach.
Cartography mode regexes: gitgalaxy/standards/language_standards/languages/*.py (per-language); labels surface in the --splicing-speed chart.
Plan
Profile-confirm the hot modes per language (COBOL Cartography_Mode_A_Labels, func_start; TS Cartography_Mode_B_Braces) via --splicing-speed on ALR and a COBOL-heavy repo.
For modes that resist gating (note: func_start was previously found "unwinnable"), evaluate regex rewrite / anchoring / removing catastrophic alternations, or a cheap pre-scan literal reject.
Correctness guard: a registry property test (mirror tests/.../test_line_gates.py) proving the gated finditer returns the identical match set as ungated for every opted-in rule.
Checklist
--splicing-speed tail captured for ALR + a COBOL-heavy repo; hot modes ranked.
pattern_is_line_local verdict recorded per hot mode.
COBOL Cartography_Mode_A_Labels gated (line or literal) OR rewrite justified.
COBOL func_start re-evaluated (prior "unwinnable" — confirm or beat).
TS Cartography_Mode_B_Braces gated/optimized.
Property test proves identical match sets for every newly gated rule.
A/B (phase_ab.py --rounds 3 --control, curl + ALR) shows Optical Detector CPU ↓ with audit.json + sarif.json byte-identical.
Golden crucible green both legs.
Verification methodology
tests/tools/phase_ab.py --repo <repo> --rounds 3 --control --engine main=<origin/main> --engine mine=<change> on curl + all_language_repo. Env: GITGALAXY_LICENSE_KEY=COMMUNITY_FREE_TIER, PYTHONPATH, KEYWORD_ROSETTA_PATH + LANGUAGE_CRUCIBLE_PATH, Bash sandbox OFF, v6/.venv python. The harness proves audit/sarif identity; the A-vs-A control separates real deltas from hash-seed noise. Judge cumulative per-worker CPU (--file-speed chart), not wall.
Lineage: builds on the prefilter/gate work in #3069 / #3072 / #3173; baseline established alongside #3175 / #3181.
Context / baseline
#3175 (largest-first worker dispatch, PR #3181) shipped output-safe but wall-flat — scheduling was never the bottleneck. A full profiled scan of
all_language_repo(16.53s wall, 1.22M LOC, 73.8k LOC/s) located the real limiters. This issue covers limiter #1: the Optical Detector regex phase. Sibling: the single-threaded tail (see companion issue).Cumulative per-worker CPU by extraction phase (÷~16 cores):
Optical Detector is 55% of all per-file work — 2× the already-gated Security Lens. And it's composition-driven, not size-driven: 26.5 ms/file on ALR vs ~10.6 ms/file on curl, because ALR contains COBOL. The
--splicing-speedtail is unambiguous:Goal
Bring Optical Detector cumulative CPU down the way #3069 / #3072 / #3173 brought down Security Lens, starting with the hottest modes.
Seam / files
gitgalaxy/core/detector.py—splice()(~L1396) runs the modes; the cache-fill deriving(rule_name, pattern, mapped_key, gate, line_gate)(~L2653) is where gates attach.gitgalaxy/core/rule_prefilter.py—derive_literal_gate(perf: the remaining speed residuals are structural — optimize the shared coding_analysis rule pass, not individual repos #3069, required-literal prefilter),pattern_is_line_local/build_line_gate/line_gated_finditer(perf: per-line gating for the line-anchored rules the literal prefilter can't touch #3072, per-line candidate scan),prefer_selectivepolicy (perf: Security_Lens is ~30% of scan CPU and completely ungated — prefilter + de-double-sweep (est. ~10% end-to-end) #3173).gitgalaxy/standards/language_standards/languages/*.py(per-language); labels surface in the--splicing-speedchart.Plan
Cartography_Mode_A_Labels,func_start; TSCartography_Mode_B_Braces) via--splicing-speedon ALR and a COBOL-heavy repo.pattern_is_line_local: if line-local, opt it into_line_gatesand attachbuild_line_gate(the perf: per-line gating for the line-anchored rules the literal prefilter can't touch #3072 path); if not line-local but literal-anchorable, attachderive_literal_gate(prefer_selective=True)(the perf: Security_Lens is ~30% of scan CPU and completely ungated — prefilter + de-double-sweep (est. ~10% end-to-end) #3173 path).func_startwas previously found "unwinnable"), evaluate regex rewrite / anchoring / removing catastrophic alternations, or a cheap pre-scan literal reject.tests/.../test_line_gates.py) proving the gated finditer returns the identical match set as ungated for every opted-in rule.Checklist
--splicing-speedtail captured for ALR + a COBOL-heavy repo; hot modes ranked.pattern_is_line_localverdict recorded per hot mode.Cartography_Mode_A_Labelsgated (line or literal) OR rewrite justified.func_startre-evaluated (prior "unwinnable" — confirm or beat).Cartography_Mode_B_Bracesgated/optimized.phase_ab.py --rounds 3 --control, curl + ALR) shows Optical Detector CPU ↓ with audit.json + sarif.json byte-identical.Verification methodology
tests/tools/phase_ab.py --repo <repo> --rounds 3 --control --engine main=<origin/main> --engine mine=<change>on curl + all_language_repo. Env:GITGALAXY_LICENSE_KEY=COMMUNITY_FREE_TIER,PYTHONPATH,KEYWORD_ROSETTA_PATH+LANGUAGE_CRUCIBLE_PATH, Bash sandbox OFF,v6/.venvpython. The harness proves audit/sarif identity; the A-vs-A control separates real deltas from hash-seed noise. Judge cumulative per-worker CPU (--file-speedchart), not wall.Lineage: builds on the prefilter/gate work in #3069 / #3072 / #3173; baseline established alongside #3175 / #3181.
🤖 Generated with Claude Code