Skip to content

perf: improve try_to_add of module concatenation #11279

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
merged 2 commits into from
Aug 5, 2025

Conversation

LingyuCoder
Copy link
Contributor

@LingyuCoder LingyuCoder commented Aug 4, 2025

Summary

  • Modify the function parameters of getCachedReadableIdentifier() to prevent unnecessary getting module instance by identifier from module graph
  • Use cached module runtime to prevent creating module runtime every time of calling try_to_add
  • Cache active states of incoming connections of modules to prevent calling is_active every time of calling try_to_add

Before:
image

After:
image

Related links

Checklist

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

Copy link

netlify bot commented Aug 4, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit a44766f
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/6890e96790ddb200088dd2ec

@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 Aug 4, 2025
Copy link
Contributor

github-actions bot commented Aug 4, 2025

📝 Benchmark detail: Open

Name Base (2025-08-04 68f5c27) Current Change
10000_big_production-mode_disable-minimize + exec 30.8 s ± 1.16 s 30.3 s ± 1.45 s -1.71 %
10000_development-mode + exec 1.77 s ± 77 ms 1.74 s ± 4.8 ms -2.09 %
10000_development-mode_hmr + exec 691 ms ± 15 ms 680 ms ± 7.9 ms -1.50 %
10000_production-mode + exec 1.83 s ± 35 ms 1.78 s ± 86 ms -2.78 %
10000_production-mode_persistent-cold + exec 1.99 s ± 102 ms 1.92 s ± 18 ms -3.37 %
10000_production-mode_persistent-hot + exec 1.43 s ± 28 ms 1.4 s ± 14 ms -2.41 %
arco-pro_development-mode + exec 1.77 s ± 55 ms 1.74 s ± 61 ms -1.21 %
arco-pro_development-mode_hmr + exec 366 ms ± 1.2 ms 366 ms ± 2.3 ms -0.07 %
arco-pro_production-mode + exec 3.3 s ± 88 ms 3.28 s ± 61 ms -0.53 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.44 s ± 184 ms 3.38 s ± 177 ms -1.62 %
arco-pro_production-mode_persistent-cold + exec 3.41 s ± 97 ms 3.35 s ± 117 ms -1.76 %
arco-pro_production-mode_persistent-hot + exec 2.06 s ± 61 ms 2.04 s ± 56 ms -1.33 %
arco-pro_production-mode_traverse-chunk-modules + exec 3.35 s ± 69 ms 3.33 s ± 31 ms -0.62 %
large-dyn-imports_development-mode + exec 1.97 s ± 20 ms 1.97 s ± 18 ms -0.08 %
large-dyn-imports_production-mode + exec 2.03 s ± 147 ms 1.98 s ± 27 ms -2.50 %
threejs_development-mode_10x + exec 1.51 s ± 30 ms 1.53 s ± 51 ms +0.91 %
threejs_development-mode_10x_hmr + exec 905 ms ± 14 ms 914 ms ± 16 ms +1.02 %
threejs_production-mode_10x + exec 4.66 s ± 194 ms 4.68 s ± 224 ms +0.42 %
threejs_production-mode_10x_persistent-cold + exec 4.79 s ± 203 ms 4.72 s ± 28 ms -1.59 %
threejs_production-mode_10x_persistent-hot + exec 4.17 s ± 28 ms 4.16 s ± 61 ms -0.24 %
10000_big_production-mode_disable-minimize + rss memory 9713 MiB ± 536 MiB 9773 MiB ± 501 MiB +0.62 %
10000_development-mode + rss memory 687 MiB ± 25.3 MiB 727 MiB ± 33.8 MiB +5.80 %
10000_development-mode_hmr + rss memory 833 MiB ± 37.5 MiB 853 MiB ± 25.6 MiB +2.37 %
10000_production-mode + rss memory 659 MiB ± 27.2 MiB 705 MiB ± 37.7 MiB +7.11 %
10000_production-mode_persistent-cold + rss memory 775 MiB ± 44.5 MiB 791 MiB ± 58.6 MiB +2.07 %
10000_production-mode_persistent-hot + rss memory 756 MiB ± 44.2 MiB 752 MiB ± 18.4 MiB -0.43 %
arco-pro_development-mode + rss memory 619 MiB ± 69.5 MiB 606 MiB ± 67.3 MiB -2.01 %
arco-pro_development-mode_hmr + rss memory 509 MiB ± 52.9 MiB 499 MiB ± 13.3 MiB -1.97 %
arco-pro_production-mode + rss memory 704 MiB ± 73.3 MiB 713 MiB ± 48.2 MiB +1.39 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 732 MiB ± 137 MiB 747 MiB ± 63.3 MiB +1.97 %
arco-pro_production-mode_persistent-cold + rss memory 782 MiB ± 108 MiB 841 MiB ± 68.2 MiB +7.54 %
arco-pro_production-mode_persistent-hot + rss memory 641 MiB ± 81.8 MiB 665 MiB ± 70.5 MiB +3.70 %
arco-pro_production-mode_traverse-chunk-modules + rss memory 712 MiB ± 114 MiB 721 MiB ± 87.3 MiB +1.28 %
large-dyn-imports_development-mode + rss memory 702 MiB ± 5.41 MiB 723 MiB ± 7.22 MiB +3.04 %
large-dyn-imports_production-mode + rss memory 606 MiB ± 4.66 MiB 630 MiB ± 10.7 MiB +3.92 %
threejs_development-mode_10x + rss memory 611 MiB ± 11.5 MiB 624 MiB ± 12 MiB +2.08 %
threejs_development-mode_10x_hmr + rss memory 828 MiB ± 46 MiB 832 MiB ± 46.6 MiB +0.41 %
threejs_production-mode_10x + rss memory 849 MiB ± 175 MiB 908 MiB ± 25.1 MiB +6.98 %
threejs_production-mode_10x_persistent-cold + rss memory 830 MiB ± 17.6 MiB 854 MiB ± 30.3 MiB +2.87 %
threejs_production-mode_10x_persistent-hot + rss memory 715 MiB ± 26.5 MiB 727 MiB ± 28.9 MiB +1.65 %

Copy link
Contributor

github-actions bot commented Aug 4, 2025

📦 Binary Size-limit

Comparing a44766f to refactor: remove redundant PluginContext and async_trait from trait Plugin (#11272) by Hana

❌ Size increased by 3.00KB from 50.31MB to 50.31MB (⬆️0.01%)

Copy link

codspeed-hq bot commented Aug 4, 2025

CodSpeed Performance Report

Merging #11279 will not alter performance

Comparing perf/improve-try-to-add (a44766f) with main (e7fa0a5)1

Summary

✅ 17 untouched benchmarks

Footnotes

  1. No successful run was found on main (c40ac65) during the generation of this report, so e7fa0a5 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@LingyuCoder LingyuCoder requested a review from JSerFeng August 4, 2025 16:49
@LingyuCoder LingyuCoder marked this pull request as ready for review August 4, 2025 16:49
@Copilot Copilot AI review requested due to automatic review settings August 4, 2025 16:49
Copy link
Contributor

@Copilot 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 improves the performance of the try_to_add function in the module concatenation plugin by implementing several caching optimizations. The changes reduce unnecessary module graph lookups, runtime calculations, and connection activity checks during module concatenation.

  • Optimizes getCachedReadableIdentifier() calls to avoid repeated module lookups
  • Caches module runtime information to prevent recalculation
  • Caches connection active states to avoid repeated is_active calls

Reviewed Changes

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

File Description
module_concatenation_plugin.rs Refactors function signatures, adds caching mechanisms for runtime and connection states, implements new helper function for optimized connection activity checks
concatenated_module.rs Updates all calls to get_cached_readable_identifier() to use new signature with module identifier instead of module instance

@LingyuCoder LingyuCoder merged commit d851122 into main Aug 5, 2025
44 checks passed
@LingyuCoder LingyuCoder deleted the perf/improve-try-to-add branch August 5, 2025 04:02
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.

2 participants