Repository navigation
Release 0.1.12: skip alternatives that cannot begin here (first-character BRANCH) - #4
Conversation
…ut a frame
Alternation is laid out flat instead of left-nested, so one frame is live per
attempted alternative and a success leaves through one jump. A new BRANCH
instruction carries the first-character set of its first arm (32 buckets,
derived from the emitted instructions and re-derived on validation); when the
next character is outside it the arm and its frame are skipped, and a chain of
such branches is decided against one read. The start-anchored claim is stored
as a validated word 7 bit instead of being derived on every search, and a
trial clears only its capture registers: repeat registers are written by
REPEAT_INIT before anything reads them. Program format 14; format 13 is
rejected.
Engine instructions per search vs 0.1.11 (Search::run over counted bindings):
the emoji-regex pattern on one-character graphemes -57.2% (on a digit -61.4%,
on a letter -44.2%), /^\p{DI}$/u on the same -9.5%, /ab|cd|ef|gh/ -33.3%,
/(foo|bar|baz)=(\d+)/ -10.0%, /a/ hit and miss -3.6% and -9.0%; no measured
case slower. See docs/branch.md.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
⛔ Files ignored due to path filters (2)
📒 Files selected for processing (18)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe program format advances to version 14. The compiler emits flattened alternations and eligible ChangesFormat 14 metadata and validation
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Refactor Sequence Diagram(s)sequenceDiagram
participant Prepared
participant ProgramValidation
participant Executor
participant Input
Prepared->>ProgramValidation: Emit BRANCH instruction and first-character mask
ProgramValidation->>ProgramValidation: Derive and validate stored mask
Input->>Executor: Provide next input character
Executor->>Executor: Compare character bucket with branch mask
Executor->>Executor: Skip excluded alternative or push backtracking frame
Merge Risk: ⚪ Minimal · up to This release adds first-character branch filtering and moves the program format to version 14. Format-13 programs are rejected on load. No concrete defect was identified, and the reported test and differential results indicate no behavior change in match answers. The change looks ready to merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 77.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 40 functions across 11 files. (7 skipped: 7 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Release 0.1.12: alternatives that cannot begin at the current character are skipped without pushing a frame. Program format 14; format-13 programs are rejected on load.
Why: Claude Code's emoji-width regex, a large alternation run once per grapheme, cost about 2,200 instructions per search. Anatomy of 0.1.11, from exact callgrind counts:
?repeat;memcmp.Changes:
BRANCHinstruction carries the first-character set of its alternative, derived from the compiled code and checked again on load. Alternatives that cannot start here are skipped without a frame, and a chain of them is decided from one read.docs/branch.md.Standalone instructions per search (0.1.11 → 0.1.12; both columns include about 65 instructions of bench-loop overhead):
1^\p{DI}$, cc mix/ab|cd|ef|gh//a/hitNo measured case got slower. The full 19-row table is in
docs/branch.md.Tests:
cargo testin debug and release: 211/0. clippy with-D warnings,fmt --checkand the Unicode table generators'--checkall pass.tests/branch.rswith 5 tests. Six injected faults each make the suite fail.Not published to crates.io. Perry then needs only
perex = "0.1.12". The measurement inside perry (micros, program set) follows before that bump.Summary by CodeRabbit
New Features
Documentation