-
-
Notifications
You must be signed in to change notification settings - Fork 757
perf(rstest): minor performance optimization #12469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for rspack canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements several micro-optimizations to improve the performance of the rstest plugin by reducing redundant operations and memory allocations.
Key changes:
- Hoisted regex compilation to a static
LazyLockto avoid recompiling the same pattern on everyprocess_assetscall - Eliminated unnecessary string allocations in
calc_mocked_targetby using string slice operations instead of converting to owned strings - Pre-allocated Vec capacity based on chunk count to reduce reallocations during file collection
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
crates/rspack_plugin_rstest/src/plugin.rs |
Moved regex compilation to static LazyLock and pre-allocated Vec capacity for file collection |
crates/rspack_plugin_rstest/src/parser_plugin.rs |
Reduced string allocations in calc_mocked_target by using &str operations and single-character pattern matching |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Rsdoctor Bundle Diff AnalysisFound 5 project(s) in monorepo. 📁 react-10kPath:
📦 Download Diff Report: react-10k Bundle Diff 📁 react-1kPath:
📦 Download Diff Report: react-1k Bundle Diff 📁 react-5kPath:
📦 Download Diff Report: react-5k Bundle Diff 📁 romePath:
📦 Download Diff Report: rome Bundle Diff 📁 ui-componentsPath:
📦 Download Diff Report: ui-components Bundle Diff Generated by Rsdoctor GitHub Action |
📦 Binary Size-limit
🎉 Size decreased by 256bytes from 48.28MB to 48.28MB (⬇️0.00%) |
CodSpeed Performance ReportMerging #12469 will not alter performanceComparing Summary
|
LazyLock will increase about 92KB binary size, which is too large. since it's not a hot code, we can keep the current code. |
chenjiahan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Summary
Hoist regex compilation to static LazyLock to avoid recompiling on every process_assets callLazyLock will increase about 92KB binary size, which is too large. since it's not a hot code, we can keep the current code.
Reduce string allocations in calc_mocked_target by using &str operations instead of to_string()
Pre-allocate Vec capacity in mock_hoist_process_assets to avoid reallocations
Related links
Checklist