Skip to content

deps(regex): take perex 0.1.4 — required-text search starts at the requested start - #10201

Closed
proggeramlug wants to merge 2 commits into
mainfrom
perf/regex-perex-0.1.4
Closed

proggeramlug wants to merge 2 commits into
mainfrom
perf/regex-perex-0.1.4

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Takes perex 0.1.4, a lock bump with no Perry source change. Part of #10165.

Problem

After #10183, JS exec/test loops still went quadratic for any pattern with required text after a class quantifier, such as /([a-z]+)([0-9]+) /g or /[a-z]+[0-9]+ /y on ASCII subjects. Each search cost O(lastIndex): for 2,000 execs starting near the end of a subject, the time doubled with its length (776 / 1,573 / 3,156 ms at 100k / 200k / 400k units), even though the remaining length was fixed.

Perry's path for these patterns is identical to the fast ones. The perex session placed the cause in Perex. Such patterns carry a "forward admission" claim: every match consumes the required text at or after its own start. The initial required-text search always began at byte 0, so the candidate bound then stepped through every earlier occurrence, each a charged round trip.

Change

perex 0.1.4 (published 2026-09-13T12:17:29Z from 0d3d3f2) starts that initial search at the requested start. This applies on ASCII storage, where the requested start is also a byte offset, and only for programs carrying the claim. Programs without the claim (for example a condition inside a lookbehind), non-ASCII storage and UTF-16 storage are unchanged. The Perex-side witnesses (every-start equivalence against the claim cleared, a bounded-work test near the end of a subject, fault injections, differentials) are in perex.

  • Checksum 1542e48011813fbdf3c075da4a4ed53ee93c816eef62e36eb5064a6fd2be10a5, verified against the downloaded perex-0.1.4.crate.
  • Locked with a one-time CARGO_RESOLVER_INCOMPATIBLE_PUBLISH_AGE=allow, approved by Ralph for 0.1.4 only. Every build and test below ran with the override unset, resolving from the lock.

Witness (perrymaster, release builds, main + this change vs #10183's head on 0.1.3, 2 alternating rounds)

2,000 execs per row on "ab12 ".repeat(n):

row len 0.1.3 0.1.4
/[a-z]+[0-9]+ /g, starting at 0 400,000 44 ms 3.4 ms
/[a-z]+[0-9]+ /g, starting at len − 10,000 100,000 788 ms 2.9 ms
200,000 1,540 ms 2.9 ms
400,000 3,218 ms 3.0 ms
/[a-z]+[0-9]+/g (control, no trailing text) 400,000 3.1 ms 2.9 ms

Whole loops, while (re.exec(s)) / while (re.test(s)) to exhaustion:

loop n Node 0.1.3 0.1.4
/([a-z]+)([0-9]+) /y 20,000 6,217 ms 39 ms
/[a-z]+[0-9]+ /y, test 20,000 5,436 ms 35 ms
/([a-z]+)([0-9]+) /y over "ab12 ".repeat(n) (reproducer row) 40,000 4.3 ms 21,455 ms (median of 3) 85 ms

Every result matches Node. Other rows of the #10183 reproducer are unchanged within noise. Non-ASCII exec/matchAll loops remain quadratic (28 s at n = 40,000); that is the separate cross-call position work.

Validation (--locked, override unset)

  • cargo metadata --locked, cargo fetch --locked
  • cargo check -p perry-runtime --no-default-features --features full --lib (regex feature off): pass
  • gc::tests::runtime_roots::perex: 91 passed; regex::: 71 passed; cargo test -p perry-perex: 27 passed, 1 ignored
  • The full perry-runtime suite, lint gates and clippy run on the merge train.

https://claude.ai/code/session_01Da12JXeG5XuVBma5yWp5C9

Summary by CodeRabbit

  • Performance
    • Improved regular expression search performance, eliminating slowdowns on large ASCII strings in affected patterns.
    • Repeated matching operations can now complete significantly faster.

Ralph Küpper added 2 commits September 13, 2026 12:20
perex 0.1.4 (published 2026-09-13T12:17:29Z from 0d3d3f2) starts the initial required-text search at the requested start on ASCII storage for programs carrying the forward-admission claim. Before this, a pattern such as /[a-z]+[0-9]+ /g paid for every earlier occurrence of its required text on each search, so JS exec/test loops over it were O(lastIndex) per call.

Checksum 1542e48011813fbdf3c075da4a4ed53ee93c816eef62e36eb5064a6fd2be10a5, verified against the downloaded crate. Locked with a one-time publish-age override approved for this version only.

Claude-Session: https://claude.ai/code/session_01Da12JXeG5XuVBma5yWp5C9
@coderabbitai

coderabbitai Bot commented Sep 13, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 48c9d6de-a07c-450e-b7c5-fe5376945e0b

📥 Commits

Reviewing files that changed from the base of the PR and between ad6925b and b141b85.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • Cargo.toml
  • changelog.d/10201-regex-perex-0.1.4.md

Included review availability: Your plan provides up to 8 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The workspace updates perex from 0.1.3 to 0.1.4. A changelog entry documents the regular-expression performance fix included in that version.

Changes

Workspace dependency update

Layer / File(s) Summary
Update perex dependency and changelog
Cargo.toml, changelog.d/10201-regex-perex-0.1.4.md
The workspace uses perex 0.1.4. The changelog records the removal of quadratic search behavior for specified regular-expression patterns.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Bug fix

Suggested reviewers: jdalton

Merge Risk: ⚪ Minimal · up to b141b

The dependency update is narrowly scoped and presents no identified merge-blocking risk.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the dependency update to perex 0.1.4 and the related performance improvement.
Description check ✅ Passed The description explains the problem, dependency change, related issue, benchmark results, checksum verification, and validation commands. It does not use all template headings or complete the checkli…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/regex-perex-0.1.4

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@proggeramlug

Copy link
Copy Markdown
Contributor Author

Landed on main via merge train 181 (#10202) as 1febaef5e0..c8b5c0d8af, with the version bump 5d3bf85f92 (0.5.1554). Validation of the combined tree is in #10202. Closing, since this landed through the train.

https://claude.ai/code/session_01Da12JXeG5XuVBma5yWp5C9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant