Skip to content
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

perf: migrate all blocking call to async call #9217

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

CPunisher
Copy link
Contributor

Summary

Related: #8312

Help me start benchmarking. I will try to polish the code further if performance improves (and split the pr).

There are still undo tasks:

  1. Many block_ons and blocking_calls are called in impl From<RawXX> for XXs, which is hard to be converted into async. Maybe we should create our own AsyncFrom.
  2. Some hooks are hard to migrate:
  3. block_on in Module trait functions: https://github.com/CPunisher/rspack/blob/87945e092d42741490ae4b36d405ce400a375149/crates/rspack_macros/src/runtime_module.rs#L189, https://github.com/CPunisher/rspack/blob/87945e092d42741490ae4b36d405ce400a375149/crates/rspack_macros/src/runtime_module.rs#L131

Checklist

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

Copy link

netlify bot commented Feb 10, 2025

Deploy Preview for rspack ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 87945e0
🔍 Latest deploy log https://app.netlify.com/sites/rspack/deploys/67a96e0ff83d85000813fc80
😎 Deploy Preview https://deploy-preview-9217--rspack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

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

github-actions bot commented Feb 10, 2025

📝 Benchmark detail: Open

Name Base (2025-02-10 09af1d8) Current Change
10000_big_production-mode_disable-minimize + exec 37.7 s ± 622 ms 38.5 s ± 829 ms +2.15 %
10000_development-mode + exec 1.87 s ± 37 ms 2.24 s ± 38 ms +19.39 %
10000_development-mode_hmr + exec 684 ms ± 18 ms 773 ms ± 32 ms +13.11 %
10000_production-mode + exec 2.31 s ± 63 ms 2.53 s ± 61 ms +9.89 %
10000_production-mode_persistent-cold + exec 2.45 s ± 74 ms 2.68 s ± 93 ms +9.47 %
10000_production-mode_persistent-hot + exec 1.64 s ± 26 ms 1.86 s ± 17 ms +13.80 %
arco-pro_development-mode + exec 1.72 s ± 90 ms 1.81 s ± 111 ms +5.39 %
arco-pro_development-mode_hmr + exec 389 ms ± 2.1 ms 397 ms ± 3.6 ms +2.13 %
arco-pro_production-mode + exec 3.62 s ± 212 ms 3.8 s ± 182 ms +5.01 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.67 s ± 262 ms 3.75 s ± 155 ms +2.27 %
arco-pro_production-mode_persistent-cold + exec 3.83 s ± 285 ms 3.95 s ± 395 ms +3.30 %
arco-pro_production-mode_persistent-hot + exec 2.36 s ± 60 ms 2.48 s ± 56 ms +5.21 %
arco-pro_production-mode_traverse-chunk-modules + exec 3.63 s ± 197 ms 3.75 s ± 231 ms +3.09 %
large-dyn-imports_development-mode + exec 2.12 s ± 39 ms 2.49 s ± 62 ms +17.32 %
large-dyn-imports_production-mode + exec 2.14 s ± 20 ms 2.56 s ± 68 ms +19.32 %
threejs_development-mode_10x + exec 1.53 s ± 28 ms 1.71 s ± 35 ms +12.18 %
threejs_development-mode_10x_hmr + exec 783 ms ± 13 ms 846 ms ± 18 ms +8.15 %
threejs_production-mode_10x + exec 5.22 s ± 186 ms 5.7 s ± 250 ms +9.13 %
threejs_production-mode_10x_persistent-cold + exec 5.31 s ± 155 ms 5.79 s ± 58 ms +9.06 %
threejs_production-mode_10x_persistent-hot + exec 4.53 s ± 315 ms 5.04 s ± 256 ms +11.29 %
10000_big_production-mode_disable-minimize + rss memory 8773 MiB ± 74.2 MiB 8741 MiB ± 65.2 MiB -0.37 %
10000_development-mode + rss memory 653 MiB ± 15.5 MiB 649 MiB ± 23.6 MiB -0.58 %
10000_development-mode_hmr + rss memory 1264 MiB ± 261 MiB 1496 MiB ± 217 MiB +18.33 %
10000_production-mode + rss memory 623 MiB ± 16.1 MiB 615 MiB ± 12.2 MiB -1.31 %
10000_production-mode_persistent-cold + rss memory 743 MiB ± 22.3 MiB 722 MiB ± 15.5 MiB -2.88 %
10000_production-mode_persistent-hot + rss memory 714 MiB ± 18.8 MiB 708 MiB ± 37 MiB -0.90 %
arco-pro_development-mode + rss memory 561 MiB ± 21.6 MiB 574 MiB ± 39.2 MiB +2.25 %
arco-pro_development-mode_hmr + rss memory 638 MiB ± 51.3 MiB 661 MiB ± 46.7 MiB +3.71 %
arco-pro_production-mode + rss memory 735 MiB ± 26.9 MiB 721 MiB ± 23.1 MiB -1.88 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 741 MiB ± 13.1 MiB 730 MiB ± 21.3 MiB -1.47 %
arco-pro_production-mode_persistent-cold + rss memory 857 MiB ± 36.2 MiB 834 MiB ± 32.3 MiB -2.75 %
arco-pro_production-mode_persistent-hot + rss memory 730 MiB ± 6.4 MiB 703 MiB ± 27.3 MiB -3.62 %
arco-pro_production-mode_traverse-chunk-modules + rss memory 737 MiB ± 60.8 MiB 712 MiB ± 24.7 MiB -3.41 %
large-dyn-imports_development-mode + rss memory 647 MiB ± 9.25 MiB 639 MiB ± 5.79 MiB -1.14 %
large-dyn-imports_production-mode + rss memory 530 MiB ± 6.21 MiB 524 MiB ± 3.87 MiB -1.20 %
threejs_development-mode_10x + rss memory 551 MiB ± 25.1 MiB 541 MiB ± 23.7 MiB -1.67 %
threejs_development-mode_10x_hmr + rss memory 1124 MiB ± 189 MiB 1149 MiB ± 127 MiB +2.22 %
threejs_production-mode_10x + rss memory 829 MiB ± 36.8 MiB 812 MiB ± 16.4 MiB -2.15 %
threejs_production-mode_10x_persistent-cold + rss memory 967 MiB ± 35.8 MiB 896 MiB ± 21.2 MiB -7.34 %
threejs_production-mode_10x_persistent-hot + rss memory 868 MiB ± 38.6 MiB 837 MiB ± 15.4 MiB -3.58 %

Threshold exceeded: ["10000_development-mode + exec","10000_development-mode_hmr + exec","10000_production-mode + exec","10000_production-mode_persistent-cold + exec","10000_production-mode_persistent-hot + exec","arco-pro_development-mode + exec","arco-pro_production-mode + exec","arco-pro_production-mode_persistent-hot + exec","large-dyn-imports_development-mode + exec","large-dyn-imports_production-mode + exec","threejs_development-mode_10x + exec","threejs_development-mode_10x_hmr + exec","threejs_production-mode_10x + exec","threejs_production-mode_10x_persistent-cold + exec","threejs_production-mode_10x_persistent-hot + exec"]

@chenjiahan
Copy link
Member

benchmark triggered 😄

@CPunisher
Copy link
Contributor Author

🤣Strange performance regression since my local tests are positive. I will continue to investigate.

@hardfist
Copy link
Contributor

@CPunisher notice that async call have performance gain when have lots of async js call but may not have performance gain(may even bring performance regression) if not have any or little js call
but 19% performance regression seems too big

})
.collect::<Vec<_>>();
let compilation = &*self;
let results = join_all(jobs.into_iter().map(|job| async move {
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems run in single thread while rayon runs in multi thread, so you may need to use spawn to run task in multi thread, this may cause performance regression now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, i realize this is not a good migration pattern

Copy link
Contributor

Choose a reason for hiding this comment

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

actually I don't know what's the perfect way to migrate these, async parallel is kind of hard in rust now

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.

3 participants