Skip to content

refactor(rspack): remove RawRegex and JsRegExp#8298

Merged
h-a-n-a merged 8 commits intoweb-infra-dev:mainfrom
shulaoda:feat/combine-raw-regex-with-js-reg-exp
Nov 4, 2024
Merged

refactor(rspack): remove RawRegex and JsRegExp#8298
h-a-n-a merged 8 commits intoweb-infra-dev:mainfrom
shulaoda:feat/combine-raw-regex-with-js-reg-exp

Conversation

@shulaoda
Copy link
Copy Markdown
Contributor

@shulaoda shulaoda commented Oct 31, 2024

Summary

Related to #8254

I ultimately removed JsRegExp and RawRegex because they both needed to be converted into RspackRegex.

The structure pub JsRegExp(JsObject) could cache the corresponding native js regex, but in reality, we never utilized it: the instance passed back to js was always a new regex instance. Therefore, I decided to abandon this approach.

I did not use #[napi(object)], opting instead to implement FromNapiValue and ToNapiValue myself, allowing for strict passing of the regex. While our implementation of FromNapiValue is not as good as the one provided by napi-rs, the ToNapiValue implementation is slightly better than the native one with js regex. Overall, the performance will still be lower, but I believe this trade-off is worthwhile. (In fact, this impact can be ignored)

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@shulaoda shulaoda marked this pull request as draft October 31, 2024 11:08
@github-actions github-actions bot added the release: feature release: feature related release(mr only) label Oct 31, 2024
@netlify
Copy link
Copy Markdown

netlify bot commented Oct 31, 2024

Deploy Preview for rspack canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit 4b679f2
🔍 Latest deploy log https://app.netlify.com/sites/rspack/deploys/67272fffcc5b6a000811c0ce

@shulaoda shulaoda changed the title feat(rspack): unify RawRegex and JsRegExp refactor(rspack): unify RawRegex and JsRegExp Oct 31, 2024
@github-actions github-actions bot removed the release: feature release: feature related release(mr only) label Oct 31, 2024
@shulaoda shulaoda force-pushed the feat/combine-raw-regex-with-js-reg-exp branch 2 times, most recently from 9ae6181 to cd47c7c Compare November 1, 2024 14:18
@shulaoda shulaoda changed the title refactor(rspack): unify RawRegex and JsRegExp refactor(rspack): remove RawRegex and JsRegExp Nov 2, 2024
@shulaoda shulaoda force-pushed the feat/combine-raw-regex-with-js-reg-exp branch from 2aabea7 to 634e378 Compare November 3, 2024 06:16
@shulaoda shulaoda force-pushed the feat/combine-raw-regex-with-js-reg-exp branch from 634e378 to 4b679f2 Compare November 3, 2024 09:10
@shulaoda shulaoda marked this pull request as ready for review November 3, 2024 11:24
@shulaoda shulaoda requested a review from h-a-n-a November 3, 2024 11:57
@h-a-n-a
Copy link
Copy Markdown
Contributor

h-a-n-a commented Nov 4, 2024

Although this might be trivial, let me still try to run bench.

@h-a-n-a
Copy link
Copy Markdown
Contributor

h-a-n-a commented Nov 4, 2024

!bench

@rspack-bot
Copy link
Copy Markdown

rspack-bot commented Nov 4, 2024

📝 Benchmark detail: Open

Name Base (2024-11-04 a987332) Current Change
10000_big_production-mode + exec 45.9 s ± 613 ms 46.6 s ± 1.06 s +1.43 %
10000_development-mode + exec 1.84 s ± 17 ms 1.85 s ± 21 ms +0.46 %
10000_development-mode_hmr + exec 645 ms ± 12 ms 649 ms ± 8.2 ms +0.67 %
10000_production-mode + exec 2.4 s ± 19 ms 2.4 s ± 30 ms +0.22 %
arco-pro_development-mode + exec 1.79 s ± 63 ms 1.77 s ± 64 ms -0.86 %
arco-pro_development-mode_hmr + exec 429 ms ± 1.2 ms 333 ms ± 54 ms -22.22 %
arco-pro_production-mode + exec 3.19 s ± 87 ms 196 ms ± 16 ms -93.84 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.27 s ± 50 ms 239 ms ± 4 ms -92.68 %
threejs_development-mode_10x + exec 1.58 s ± 7.7 ms 1.57 s ± 20 ms -0.55 %
threejs_development-mode_10x_hmr + exec 784 ms ± 4.2 ms 781 ms ± 15 ms -0.38 %
threejs_production-mode_10x + exec 4.93 s ± 40 ms 4.94 s ± 17 ms +0.20 %

@h-a-n-a
Copy link
Copy Markdown
Contributor

h-a-n-a commented Nov 4, 2024

📝 Benchmark detail: Open

Name Base (2024-11-04 a987332) Current Change
10000_big_production-mode + exec 45.9 s ± 613 ms 46.6 s ± 1.06 s +1.43 %
10000_development-mode + exec 1.84 s ± 17 ms 1.85 s ± 21 ms +0.46 %
10000_development-mode_hmr + exec 645 ms ± 12 ms 649 ms ± 8.2 ms +0.67 %
10000_production-mode + exec 2.4 s ± 19 ms 2.4 s ± 30 ms +0.22 %
arco-pro_development-mode + exec 1.79 s ± 63 ms 1.77 s ± 64 ms -0.86 %
arco-pro_development-mode_hmr + exec 429 ms ± 1.2 ms 333 ms ± 54 ms -22.22 %
arco-pro_production-mode + exec 3.19 s ± 87 ms 196 ms ± 16 ms -93.84 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.27 s ± 50 ms 239 ms ± 4 ms -92.68 %
threejs_development-mode_10x + exec 1.58 s ± 7.7 ms 1.57 s ± 20 ms -0.55 %
threejs_development-mode_10x_hmr + exec 784 ms ± 4.2 ms 781 ms ± 15 ms -0.38 %
threejs_production-mode_10x + exec 4.93 s ± 40 ms 4.94 s ± 17 ms +0.20 %

The benchmark looks very weird in some cases. It's good to merge though ;-). Thanks!

@h-a-n-a h-a-n-a merged commit 4d1c348 into web-infra-dev:main Nov 4, 2024
@shulaoda shulaoda deleted the feat/combine-raw-regex-with-js-reg-exp branch November 4, 2024 09:29
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.

3 participants