Skip to content

perf: parallelize flag usage plugin#11128

Merged
LingyuCoder merged 1 commit intomainfrom
refactor/flag-usage
Jul 22, 2025
Merged

perf: parallelize flag usage plugin#11128
LingyuCoder merged 1 commit intomainfrom
refactor/flag-usage

Conversation

@LingyuCoder
Copy link
Contributor

@LingyuCoder LingyuCoder commented Jul 22, 2025

Summary

This is a new implement of flag dependency usage plugin strategy just like the part of #10712 but consider of the get mode cache and repeat modules. The same is process modules in batches but keep Queue and cache to avoid repeat computing.

And also this PR has been tested in rome case and will not lead to performance regression.

Before:
image

After:
image

Related links

Checklist

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

@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 Jul 22, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Jul 22, 2025

📝 Ecosystem CI detail: Open

suite result
modernjs ✅ success
rsbuild ✅ success
rslib ❌ failure
rspress ✅ success
examples ✅ success
plugin ✅ success
nuxt ✅ success
lynx-stack ❌ failure
rsdoctor ✅ success
devserver ✅ success

@netlify
Copy link

netlify bot commented Jul 22, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 9f0dc07
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/687f4e77b0465c00089b5bd1

@github-actions
Copy link
Contributor

📦 Binary Size-limit

Comparing 9f0dc07 to chore(deps): update napi (#10865) by renovate[bot]

❌ Size increased by 16.13KB from 48.95MB to 48.97MB (⬆️0.03%)

@github-actions
Copy link
Contributor

github-actions bot commented Jul 22, 2025

📝 Benchmark detail: Open

Name Base (2025-07-22 b4c248d) Current Change
10000_big_production-mode_disable-minimize + exec 30 s ± 834 ms 30.4 s ± 332 ms +1.12 %
10000_development-mode + exec 1.79 s ± 44 ms 1.74 s ± 31 ms -2.83 %
10000_development-mode_hmr + exec 705 ms ± 5.5 ms 692 ms ± 20 ms -1.81 %
10000_production-mode + exec 1.87 s ± 20 ms 1.88 s ± 41 ms +0.21 %
10000_production-mode_persistent-cold + exec 2.03 s ± 46 ms 2 s ± 30 ms -1.91 %
10000_production-mode_persistent-hot + exec 1.49 s ± 45 ms 1.48 s ± 41 ms -0.95 %
arco-pro_development-mode + exec 1.78 s ± 86 ms 1.82 s ± 108 ms +1.83 %
arco-pro_development-mode_hmr + exec 368 ms ± 1.2 ms 368 ms ± 1.5 ms 0.00 %
arco-pro_production-mode + exec 3.31 s ± 59 ms 3.33 s ± 287 ms +0.82 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.39 s ± 121 ms 3.35 s ± 72 ms -1.26 %
arco-pro_production-mode_persistent-cold + exec 3.37 s ± 73 ms 3.35 s ± 78 ms -0.58 %
arco-pro_production-mode_persistent-hot + exec 2.09 s ± 94 ms 2.08 s ± 44 ms -0.60 %
arco-pro_production-mode_traverse-chunk-modules + exec 3.34 s ± 70 ms 3.31 s ± 40 ms -0.94 %
large-dyn-imports_development-mode + exec 2 s ± 81 ms 2.02 s ± 244 ms +1.03 %
large-dyn-imports_production-mode + exec 1.92 s ± 26 ms 1.96 s ± 20 ms +1.98 %
threejs_development-mode_10x + exec 1.54 s ± 30 ms 1.54 s ± 46 ms -0.22 %
threejs_development-mode_10x_hmr + exec 923 ms ± 20 ms 914 ms ± 18 ms -0.99 %
threejs_production-mode_10x + exec 4.66 s ± 26 ms 4.67 s ± 217 ms +0.27 %
threejs_production-mode_10x_persistent-cold + exec 4.75 s ± 64 ms 4.81 s ± 277 ms +1.31 %
threejs_production-mode_10x_persistent-hot + exec 4.22 s ± 262 ms 4.22 s ± 91 ms -0.18 %
10000_big_production-mode_disable-minimize + rss memory 9672 MiB ± 103 MiB 9739 MiB ± 277 MiB +0.70 %
10000_development-mode + rss memory 684 MiB ± 15.3 MiB 703 MiB ± 19.5 MiB +2.85 %
10000_development-mode_hmr + rss memory 824 MiB ± 48.5 MiB 836 MiB ± 59.1 MiB +1.51 %
10000_production-mode + rss memory 648 MiB ± 9.91 MiB 705 MiB ± 45.9 MiB +8.78 %
10000_production-mode_persistent-cold + rss memory 764 MiB ± 28.3 MiB 781 MiB ± 30.7 MiB +2.22 %
10000_production-mode_persistent-hot + rss memory 745 MiB ± 16.6 MiB 757 MiB ± 48.1 MiB +1.64 %
arco-pro_development-mode + rss memory 614 MiB ± 25 MiB 615 MiB ± 27.1 MiB +0.09 %
arco-pro_development-mode_hmr + rss memory 492 MiB ± 11.3 MiB 512 MiB ± 16.1 MiB +4.25 %
arco-pro_production-mode + rss memory 691 MiB ± 43.5 MiB 703 MiB ± 80.2 MiB +1.71 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 715 MiB ± 70.4 MiB 712 MiB ± 65.5 MiB -0.31 %
arco-pro_production-mode_persistent-cold + rss memory 799 MiB ± 76.4 MiB 800 MiB ± 41 MiB +0.18 %
arco-pro_production-mode_persistent-hot + rss memory 653 MiB ± 92.7 MiB 672 MiB ± 68.9 MiB +2.95 %
arco-pro_production-mode_traverse-chunk-modules + rss memory 698 MiB ± 79.6 MiB 729 MiB ± 126 MiB +4.50 %
large-dyn-imports_development-mode + rss memory 690 MiB ± 5.82 MiB 720 MiB ± 17.6 MiB +4.38 %
large-dyn-imports_production-mode + rss memory 613 MiB ± 931 KiB 647 MiB ± 10.2 MiB +5.61 %
threejs_development-mode_10x + rss memory 604 MiB ± 10.5 MiB 635 MiB ± 9.96 MiB +5.26 %
threejs_development-mode_10x_hmr + rss memory 818 MiB ± 42.5 MiB 847 MiB ± 32.5 MiB +3.51 %
threejs_production-mode_10x + rss memory 776 MiB ± 196 MiB 879 MiB ± 151 MiB +13.34 %
threejs_production-mode_10x_persistent-cold + rss memory 835 MiB ± 32 MiB 838 MiB ± 16.8 MiB +0.40 %
threejs_production-mode_10x_persistent-hot + rss memory 684 MiB ± 6.1 MiB 718 MiB ± 31.1 MiB +4.99 %

@codspeed-hq
Copy link

codspeed-hq bot commented Jul 22, 2025

CodSpeed Performance Report

Merging #11128 will not alter performance

Comparing refactor/flag-usage (9f0dc07) with main (b9ec3fd)

🎉 Hooray! codspeed-rust just leveled up to 2.7.2!

A heads-up, this is a breaking change and it might affect your current performance baseline a bit. But here's the exciting part - it's packed with new, cool features and promises improved result stability 🥳!
Curious about what's new? Visit our releases page to delve into all the awesome details about this new version.

Summary

✅ 16 untouched benchmarks

@LingyuCoder LingyuCoder requested a review from ahabhgk July 22, 2025 09:57
@LingyuCoder LingyuCoder changed the title perf: parallel flag usage plugin perf: parallelize flag usage plugin Jul 22, 2025
@LingyuCoder LingyuCoder marked this pull request as ready for review July 22, 2025 09:57
Copilot AI review requested due to automatic review settings July 22, 2025 09:57
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 parallelizes the flag dependency usage plugin to improve build performance by processing modules in batches using Rayon's parallel iterators while maintaining a queue and cache to avoid redundant computations.

  • Refactored the main processing loop to collect modules into batches and process them in parallel
  • Extracted logic into separate functions (merge_referenced_exports, collect_active_dependencies, get_dependency_referenced_exports) for better modularity and parallelization
  • Added an is_empty() method to the Queue utility for proper batch processing control

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
crates/rspack_util/src/queue.rs Added is_empty() method to support batch processing logic
crates/rspack_plugin_javascript/src/plugin/flag_dependency_usage_plugin.rs Complete refactoring to support parallel processing with extracted helper functions and batch-based module processing

@LingyuCoder LingyuCoder merged commit 68e7c22 into main Jul 22, 2025
67 of 75 checks passed
@LingyuCoder LingyuCoder deleted the refactor/flag-usage branch July 22, 2025 09:59
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