Skip to content

perf: reduce memory allocation in esm_export_imported_specifier_dependency #10657

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

Merged

Conversation

CPunisher
Copy link
Contributor

@CPunisher CPunisher commented Jun 13, 2025

Summary

Some performance improvements after #10584

  1. Split ExportsMode to enum variants and box the DynamicReexport case since it's larger than other variants. Data size: 112 bytes -> 40 bytes. This change also eliminates unnecessary Option::expect.
  2. Avoid unnecessary Vec to HashSet reallocation. The data structures I change from Vec to HashSet in this pr are actually Sets in webpack.
  3. Use map.clear rather than reallocate a new map in the loop.

Checklist

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

@CPunisher CPunisher requested a review from LingyuCoder June 13, 2025 02:25
Copy link

netlify bot commented Jun 13, 2025

Deploy Preview for rspack canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit cd135c4
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/684be5e0f31b670008272e96

@github-actions github-actions bot added the release: performance release: performance related release(mr only) label Jun 13, 2025
Copy link

codspeed-hq bot commented Jun 13, 2025

CodSpeed Performance Report

Merging #10657 will create unknown performance changes

Comparing CPunisher:06-12-perf/module-graph-cache-1 (cd135c4) with main (7c97b3d)

Summary

🆕 12 new benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
🆕 rust@bundle-basic N/A 4 ms N/A
🆕 rust@bundle-basic_sourcemap N/A 4.2 ms N/A
🆕 rust@build_chunk_graph N/A 96.3 ms N/A
🆕 rust@build_chunk_graph_parallel N/A 74.5 ms N/A
🆕 js@Traverse compilation.modules N/A 66.8 µs N/A
🆕 js@Traverse module graph by connections N/A 289.6 µs N/A
🆕 js@Traverse module graph by dependencies N/A 557.4 µs N/A
🆕 js@collect imported identifiers N/A 221.8 µs N/A
🆕 js@is css mod N/A 90.6 µs N/A
🆕 js@record chunk group N/A 91 µs N/A
🆕 js@record module N/A 2 ms N/A
🆕 [email protected]() N/A 25.4 ms N/A

@CPunisher CPunisher force-pushed the 06-12-perf/module-graph-cache-1 branch from 4bc6561 to 233b1c6 Compare June 13, 2025 07:52
@hardfist
Copy link
Contributor

nice job! it's meaningful to remove unnecessary unwrap, we have too much unnecessary now

LingyuCoder
LingyuCoder previously approved these changes Jun 13, 2025
Copy link
Contributor

@LingyuCoder LingyuCoder left a comment

Choose a reason for hiding this comment

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

LGTM, should run benchmark before merging

Copy link
Contributor

github-actions bot commented Jun 13, 2025

📝 Benchmark detail: Open

Name Base (2025-06-13 3c8b4b8) Current Change
10000_big_production-mode_disable-minimize + exec 35.3 s ± 419 ms 36.2 s ± 385 ms +2.35 %
10000_development-mode + exec 1.88 s ± 16 ms 1.87 s ± 155 ms -0.59 %
10000_development-mode_hmr + exec 711 ms ± 14 ms 701 ms ± 18 ms -1.47 %
10000_production-mode + exec 2.38 s ± 36 ms 2.3 s ± 44 ms -3.42 %
10000_production-mode_persistent-cold + exec 2.54 s ± 51 ms 2.47 s ± 33 ms -2.66 %
10000_production-mode_persistent-hot + exec 1.81 s ± 22 ms 1.77 s ± 168 ms -2.39 %
arco-pro_development-mode + exec 1.81 s ± 102 ms 1.82 s ± 63 ms +0.66 %
arco-pro_development-mode_hmr + exec 369 ms ± 2.2 ms 370 ms ± 0.75 ms +0.15 %
arco-pro_production-mode + exec 3.39 s ± 114 ms 3.35 s ± 34 ms -1.31 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.5 s ± 125 ms 3.49 s ± 384 ms -0.50 %
arco-pro_production-mode_persistent-cold + exec 3.48 s ± 66 ms 3.45 s ± 114 ms -0.90 %
arco-pro_production-mode_persistent-hot + exec 2.07 s ± 98 ms 2.1 s ± 154 ms +1.30 %
arco-pro_production-mode_traverse-chunk-modules + exec 3.42 s ± 40 ms 3.41 s ± 100 ms -0.34 %
large-dyn-imports_development-mode + exec 2.1 s ± 44 ms 2.08 s ± 11 ms -0.86 %
large-dyn-imports_production-mode + exec 2.11 s ± 24 ms 2.08 s ± 32 ms -1.79 %
threejs_development-mode_10x + exec 1.48 s ± 58 ms 1.46 s ± 27 ms -1.08 %
threejs_development-mode_10x_hmr + exec 834 ms ± 23 ms 837 ms ± 32 ms +0.33 %
threejs_production-mode_10x + exec 4.84 s ± 192 ms 4.87 s ± 367 ms +0.57 %
threejs_production-mode_10x_persistent-cold + exec 4.94 s ± 49 ms 5.01 s ± 301 ms +1.30 %
threejs_production-mode_10x_persistent-hot + exec 4.26 s ± 114 ms 4.23 s ± 37 ms -0.67 %
10000_big_production-mode_disable-minimize + rss memory 9286 MiB ± 182 MiB 9159 MiB ± 159 MiB -1.36 %
10000_development-mode + rss memory 651 MiB ± 31.2 MiB 694 MiB ± 39.2 MiB +6.62 %
10000_development-mode_hmr + rss memory 791 MiB ± 11 MiB 805 MiB ± 33.2 MiB +1.69 %
10000_production-mode + rss memory 643 MiB ± 83.5 MiB 684 MiB ± 66.1 MiB +6.38 %
10000_production-mode_persistent-cold + rss memory 761 MiB ± 53.6 MiB 788 MiB ± 9.87 MiB +3.54 %
10000_production-mode_persistent-hot + rss memory 774 MiB ± 43.5 MiB 733 MiB ± 65.2 MiB -5.29 %
arco-pro_development-mode + rss memory 607 MiB ± 69.3 MiB 628 MiB ± 64.4 MiB +3.41 %
arco-pro_development-mode_hmr + rss memory 497 MiB ± 43.2 MiB 514 MiB ± 54.8 MiB +3.37 %
arco-pro_production-mode + rss memory 722 MiB ± 97.2 MiB 742 MiB ± 109 MiB +2.80 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 747 MiB ± 80.9 MiB 724 MiB ± 45 MiB -3.04 %
arco-pro_production-mode_persistent-cold + rss memory 816 MiB ± 124 MiB 825 MiB ± 78.4 MiB +1.13 %
arco-pro_production-mode_persistent-hot + rss memory 665 MiB ± 71.7 MiB 687 MiB ± 96 MiB +3.35 %
arco-pro_production-mode_traverse-chunk-modules + rss memory 712 MiB ± 83.1 MiB 711 MiB ± 57.2 MiB -0.25 %
large-dyn-imports_development-mode + rss memory 695 MiB ± 19.5 MiB 693 MiB ± 6.53 MiB -0.32 %
large-dyn-imports_production-mode + rss memory 575 MiB ± 5.26 MiB 576 MiB ± 7.21 MiB +0.19 %
threejs_development-mode_10x + rss memory 658 MiB ± 12.3 MiB 670 MiB ± 14.3 MiB +1.94 %
threejs_development-mode_10x_hmr + rss memory 862 MiB ± 46.8 MiB 839 MiB ± 64.6 MiB -2.67 %
threejs_production-mode_10x + rss memory 920 MiB ± 58 MiB 929 MiB ± 18.7 MiB +0.97 %
threejs_production-mode_10x_persistent-cold + rss memory 1004 MiB ± 26.4 MiB 1009 MiB ± 48.4 MiB +0.53 %
threejs_production-mode_10x_persistent-hot + rss memory 866 MiB ± 36.2 MiB 852 MiB ± 42.9 MiB -1.61 %

@LingyuCoder LingyuCoder merged commit 61fd95a into web-infra-dev:main Jun 13, 2025
34 checks passed
@CPunisher CPunisher deleted the 06-12-perf/module-graph-cache-1 branch June 13, 2025 09:52
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.

4 participants