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
{{ message }}
Repository navigation
Use Perex literal-prefix execution without DFA storage - #12792
Start-anchored literal programs such as /^--/ now compare the original subject with immutable Perex program data before consulting the DFA. Prefix programs carry no DFA cache and need no evaluator scratch. Literal evaluation continues to create a fresh RegExp object with isolated lastIndex around shared matcher data.
Uses published perex 0.1.14, released through Perex #6. Cargo.lock pins the verified registry artifact; no path or git override remains. The documented one-time publish-age resolution leaves the global seven-day policy unchanged.
Both arms were built and measured on qb7 from common parent bc00158c1, using instructions:u n=3 medians, with exact Node output parity:
Witness
Base instructions
Head instructions
Delta
.text delta
commander
2,868,681,289
2,853,650,581
-0.5240%
+2,304 B
qs_parse
9,001,137,263
9,001,350,246
+0.0024%
+1,920 B
marked
397,143,828
397,835,410
+0.1741%
+1,520 B
effect (noopt)
6,056,051,462
6,056,137,612
+0.0014%
+3,072 B
1M anchored replacements
3,700,610,012
3,568,976,865
-3.5571%
+1,520 B
Commander’s DFA sample share falls 2.24% → 1.34%. The small marked cost is in prefix-descriptor admission (program_bounds / perex::dfa::find); qs_parse and effect are effectively flat. Paired perrymaster wall/RSS samples are recorded with host load; short-run wall timings overlap substantially under shared-host load.
Validation: final-head pmcheck passed: unified registry build, sidecars, zod/tsc smokes and 92 instrumented regex unit tests (single-threaded). Nine final regex gap files match both Node 26.5.1 and 26.8.1; Windows runtime+stdlib cargo-xwin checks pass. Perex fmt/check/clippy, 460 debug/release unit/doc tests, engine differential harness (zero unreviewed differences), and package verification pass. Local related runtime coverage also passed 108 tests. Symbol-preserving profiling binaries have byte-identical .text.
Fresh literal identities, lastIndex mutation, sticky/global flags, multiline anchors, Unicode/surrogate starts, templates, callbacks and overridden exec are covered. Current main already shares literal matcher data. Reuse owns no per-operation buffer; source/disassembly shows allocation only on cold handle-stack capacity growth.
Summary by CodeRabbit
Performance
Anchored literal regular expressions now use a faster matching path, including for Unicode patterns and different starting positions.
This optimization preserves expected behavior for replacements, captures, flags, and each regular expression’s independent lastIndex state.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
📝 Walkthrough
The Perex dependency is updated to 0.1.14. The runtime tries exact literal-prefix execution before the lazy DFA. Cache allocation and tests are updated for anchored literal patterns and their RegExp behavior.
Changes: Anchored literal execution
Layer / File(s)
Summary
Perex version and cache allocation Cargo.toml, crates/perry-runtime/src/regex/perex_owner.rs
The workspace updates Perex from 0.1.13 to 0.1.14. Programs with a zero-word DFA minimum now receive zero DFA cache words.
Prefix execution and regression coverage crates/perry-runtime/src/regex/perex_runtime.rs, crates/perry-runtime/src/regex/perex_runtime/dfa_tests.rs, test-files/test_gap_regexp_anchored_literal_prefix.ts, changelog.d/12792-perex-anchored-literal.md
program_bounds tries the literal-prefix executor before the DFA and maps prefix results to bounds without capture groups. Tests check prefix results, DFA and evaluator counters, and RegExp replacement behavior. The changelog records the executor and per-evaluation RegExp state.
sequenceDiagram
participant search
participant program_bounds
participant literalPrefixExecutor
participant lazyDFA
search->>program_bounds: Request bounds
program_bounds->>literalPrefixExecutor: Search program prefix from start
alt Prefix available
literalPrefixExecutor-->>program_bounds: Return match or no-match bounds
else No prefix available
program_bounds->>lazyDFA: Evaluate program
lazyDFA-->>program_bounds: Return DFA result
end
program_bounds-->>search: Return bounds
Loading
Merge Risk:⚪ Minimal · up to d4f60
This change adds a fast path for start-anchored literal regexes and updates the Perex dependency. No concrete merge-blocking risk was identified in the supplied context, and the new tests cover the main RegExp behaviors.
Pre-merge checks: 5
Check name
Status
Explanation
Docstring Coverage
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 4 files. (2 skipped: 2 …
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Title check
The title clearly and concisely identifies the main change: using Perex literal-prefix execution without DFA storage.
Description check
The description provides a detailed summary of the implementation, performance results, and validation. It covers the substantive Summary, Changes, and Test plan content, but it does not use the templ…
Full details: Docstring Coverage
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 4 files. (2 skipped: 2 unsupported.)
Full details: Description check
Explanation
The description provides a detailed summary of the implementation, performance results, and validation. It covers the substantive Summary, Changes, and Test plan content, but it does not use the template headings or explicitly provide a Related issue, Screenshots / output, or Checklist section.
✨ Finishing Touches
📝 Generate docstrings
Commit to this branch
Create a new PR
🧪 Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Start-anchored literal programs such as
/^--/now compare the original subject with immutable Perex program data before consulting the DFA. Prefix programs carry no DFA cache and need no evaluator scratch. Literal evaluation continues to create a fresh RegExp object with isolated lastIndex around shared matcher data.Uses published perex 0.1.14, released through Perex #6. Cargo.lock pins the verified registry artifact; no path or git override remains. The documented one-time publish-age resolution leaves the global seven-day policy unchanged.
Both arms were built and measured on qb7 from common parent
bc00158c1, using instructions:u n=3 medians, with exact Node output parity:Commander’s DFA sample share falls 2.24% → 1.34%. The small marked cost is in prefix-descriptor admission (
program_bounds/perex::dfa::find); qs_parse and effect are effectively flat. Paired perrymaster wall/RSS samples are recorded with host load; short-run wall timings overlap substantially under shared-host load.Validation: final-head pmcheck passed: unified registry build, sidecars, zod/tsc smokes and 92 instrumented regex unit tests (single-threaded). Nine final regex gap files match both Node 26.5.1 and 26.8.1; Windows runtime+stdlib cargo-xwin checks pass. Perex fmt/check/clippy, 460 debug/release unit/doc tests, engine differential harness (zero unreviewed differences), and package verification pass. Local related runtime coverage also passed 108 tests. Symbol-preserving profiling binaries have byte-identical .text.
Fresh literal identities, lastIndex mutation, sticky/global flags, multiline anchors, Unicode/surrogate starts, templates, callbacks and overridden exec are covered. Current main already shares literal matcher data. Reuse owns no per-operation buffer; source/disassembly shows allocation only on cold handle-stack capacity growth.
Summary by CodeRabbit
lastIndexstate.