Skip to content

perf(regex): prefer native regex fallback#14013

Draft
LingyuCoder wants to merge 5 commits into
mainfrom
codex/native-regex-first
Draft

perf(regex): prefer native regex fallback#14013
LingyuCoder wants to merge 5 commits into
mainfrom
codex/native-regex-first

Conversation

@LingyuCoder
Copy link
Copy Markdown
Contributor

@LingyuCoder LingyuCoder commented May 12, 2026

Summary

  • try Rust native regex via RegexBuilder before falling back to regress
  • keep the existing EndWith fast path ahead of the native-regex attempt
  • add a .* match-all fast path in Algo::new so the default wrapped context regexp does not need backend regex compilation
  • align flag handling with Turbopack for d/g/i/m/s/u, while keeping sticky y on regress for correctness outside the .* fast path
  • normalize escaped JS regex slashes (\/) before constructing Rust regex
  • port relevant Turbopack behavior tests for simple native regex, negative lookahead fallback, invalid regex, and the .* fast path

Validation

  • cargo test -p rspack_regex
  • cargo check -p rspack --lib
  • cargo fmt --all --check
  • git diff --check

@github-actions github-actions Bot added the release: performance release: performance related release(mr only) label May 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 12, 2026

📦 Binary Size-limit

Comparing 6cab50a to feat(css): add support for css/global module type (#13988) by AsyncIter

❌ Size increased by 12.00KB from 61.92MB to 61.94MB (⬆️0.02%)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 12, 2026

Rsdoctor Bundle Diff Analysis

⚠️ Note: The latest commit (400d3d7c3e) does not have baseline artifacts. Using commit f5cdf19587 for baseline comparison instead. If this seems incorrect, please wait a few minutes and try rerunning the workflow.

Found 6 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Change
popular-libs 1.7 MB 0
react-10k 5.7 MB 0
react-1k 826.3 KB 0
react-5k 2.7 MB 0
rome 1.6 MB 0
ui-components 4.8 MB 0

Generated by Rsdoctor GitHub Action

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 12, 2026

Merging this PR will not alter performance

✅ 34 untouched benchmarks
⏩ 25 skipped benchmarks1


Comparing codex/native-regex-first (6cab50a) with main (f5cdf19)

Open in CodSpeed

Footnotes

  1. 25 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@LingyuCoder LingyuCoder force-pushed the codex/native-regex-first branch from 4163dd8 to ca15bbb Compare May 12, 2026 08:28
@LingyuCoder
Copy link
Copy Markdown
Contributor Author

@copilot remove "unicode-case" feature of regex crate

Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

@copilot remove "unicode-case" feature of regex crate

Done in eef0be3 (with follow-up fixes in 933d255 and cce2542): removed unicode-case from the workspace regex dependency and adjusted native-regex fallback/tests accordingly. No UI changes in this PR, so no screenshot applies.

@hardfist hardfist force-pushed the codex/native-regex-first branch from a16b4fa to cce2542 Compare May 13, 2026 05:10
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 13, 2026

Deploying rspack with  Cloudflare Pages  Cloudflare Pages

Latest commit: cce2542
Status: ✅  Deploy successful!
Preview URL: https://947a8c83.rspack-v2.pages.dev
Branch Preview URL: https://codex-native-regex-first.rspack-v2.pages.dev

View logs

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

Labels

release: performance release: performance related release(mr only)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants