Skip to content

Conversation

@fi3ework
Copy link
Member

@fi3ework fi3ework commented Dec 16, 2025

Summary

  • Hoist regex compilation to static LazyLock to avoid recompiling on every process_assets call

    ❌ Size increased by 92.63KB from 48.19MB to 48.28MB (⬆️0.19%)

    LazyLock 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

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

Copilot AI review requested due to automatic review settings December 16, 2025 08:27
@netlify
Copy link

netlify bot commented Dec 16, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit a80c495
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/694139a89f49040008ae84c5

@github-actions github-actions bot added release: performance release: performance related release(mr only) team The issue/pr is created by the member of Rspack. labels Dec 16, 2025
Copy link
Contributor

Copilot AI left a 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 LazyLock to avoid recompiling the same pattern on every process_assets call
  • Eliminated unnecessary string allocations in calc_mocked_target by 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.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 16, 2025

Rsdoctor Bundle Diff Analysis

Found 5 project(s) in monorepo.

📁 react-10k

Path: ../build-tools-performance/cases/react-10k/dist/rsdoctor-data.json

📌 Baseline Commit: 5fade2fad0 | PR: #12445

Metric Current Baseline Change
📊 Total Size 5.7 MB 5.7 MB 153.0 B (0.0%)
📄 JavaScript 5.7 MB 5.7 MB 153.0 B (0.0%)
🎨 CSS 21.0 B 21.0 B 0 B (0.0%)
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: react-10k Bundle Diff

📁 react-1k

Path: ../build-tools-performance/cases/react-1k/dist/rsdoctor-data.json

📌 Baseline Commit: 5fade2fad0 | PR: #12445

Metric Current Baseline Change
📊 Total Size 823.6 KB 823.4 KB 153.0 B (0.0%)
📄 JavaScript 823.6 KB 823.4 KB 153.0 B (0.0%)
🎨 CSS 0 B 0 B N/A
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: react-1k Bundle Diff

📁 react-5k

Path: ../build-tools-performance/cases/react-5k/dist/rsdoctor-data.json

📌 Baseline Commit: 5fade2fad0 | PR: #12445

Metric Current Baseline Change
📊 Total Size 2.7 MB 2.7 MB 153.0 B (0.0%)
📄 JavaScript 2.7 MB 2.7 MB 153.0 B (0.0%)
🎨 CSS 21.0 B 21.0 B 0 B (0.0%)
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: react-5k Bundle Diff

📁 rome

Path: ../build-tools-performance/cases/rome/dist/rsdoctor-data.json

📌 Baseline Commit: 5fade2fad0 | PR: #12445

Metric Current Baseline Change
📊 Total Size 984.3 KB 984.3 KB 0 B (0.0%)
📄 JavaScript 984.3 KB 984.3 KB 0 B (0.0%)
🎨 CSS 0 B 0 B N/A
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: rome Bundle Diff

📁 ui-components

Path: ../build-tools-performance/cases/ui-components/dist/rsdoctor-data.json

📌 Baseline Commit: 5fade2fad0 | PR: #12445

Metric Current Baseline Change
📊 Total Size 2.1 MB 2.1 MB 1.6 KB (0.1%)
📄 JavaScript 2.0 MB 2.0 MB 1.6 KB (0.1%)
🎨 CSS 83.0 KB 83.0 KB 0 B (0.0%)
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: ui-components Bundle Diff

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Contributor

github-actions bot commented Dec 16, 2025

📦 Binary Size-limit

Comparing a80c495 to feat(deps)!: bump swc_core from 46.0.3 to 50.2.3 and swc_experimental (#12445) by CPunisher

🎉 Size decreased by 256bytes from 48.28MB to 48.28MB (⬇️0.00%)

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 16, 2025

CodSpeed Performance Report

Merging #12469 will not alter performance

Comparing msg (a80c495) with main (5fade2f)

Summary

✅ 17 untouched

@fi3ework
Copy link
Member Author

❌ Size increased by 92.63KB from 48.19MB to 48.28MB (⬆️0.19%)

LazyLock will increase about 92KB binary size, which is too large. since it's not a hot code, we can keep the current code.

@fi3ework fi3ework requested a review from chenjiahan December 16, 2025 12:07
Copy link
Member

@chenjiahan chenjiahan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

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) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants