rspack icon indicating copy to clipboard operation
rspack copied to clipboard

perf: cache swc loader

Open CPunisher opened this issue 1 year ago • 4 comments

Summary

Checklist

Assume:

  1. Creating an SwcLoaderJsOptions is costly
  2. Most modules are created with same swc loader options

Cost:

  1. RwLock and concurrent runtime. Maybe there is a better cache strategy.

🙏 Help me run the benchmark.

  • [x] Tests updated (or not required).
  • [x] Documentation updated (or not required).

CPunisher avatar Sep 24 '24 11:09 CPunisher

Deploy Preview for rspack canceled.

Built without sensitive environment variables

Name Link
Latest commit e0e0f29ea35682973ca40f818a1c281c64c24307
Latest deploy log https://app.netlify.com/sites/rspack/deploys/670a8d0c4d213a0008217b79

netlify[bot] avatar Sep 24 '24 11:09 netlify[bot]

!bench

JSerFeng avatar Sep 25 '24 10:09 JSerFeng

📝 Benchmark detail: Open

Name Base (2024-09-25 5fd46ef) Current Change
10000_development-mode + exec 2.27 s ± 30 ms 2.23 s ± 23 ms -1.93 %
10000_development-mode_hmr + exec 701 ms ± 15 ms 704 ms ± 12 ms +0.34 %
10000_production-mode + exec 2.93 s ± 20 ms 2.89 s ± 38 ms -1.51 %
arco-pro_development-mode + exec 1.84 s ± 80 ms 1.87 s ± 93 ms +1.72 %
arco-pro_development-mode_hmr + exec 436 ms ± 2.9 ms 436 ms ± 3.4 ms -0.09 %
arco-pro_production-mode + exec 3.32 s ± 72 ms 3.29 s ± 91 ms -0.76 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.35 s ± 98 ms 3.38 s ± 79 ms +0.96 %
threejs_development-mode_10x + exec 1.7 s ± 17 ms 1.7 s ± 14 ms -0.06 %
threejs_development-mode_10x_hmr + exec 788 ms ± 9.3 ms 792 ms ± 15 ms +0.47 %
threejs_production-mode_10x + exec 5.26 s ± 11 ms 5.27 s ± 34 ms +0.01 %

rspack-bot avatar Sep 25 '24 10:09 rspack-bot

Thanks.

Modules in our bench cases are not that many, so the benefits may not be so obvious, but personally I think it's great for some large projects

JSerFeng avatar Sep 25 '24 10:09 JSerFeng

@JSerFeng can we merge this

chenjiahan avatar Oct 11 '24 13:10 chenjiahan

!eco-ci

chenjiahan avatar Oct 11 '24 13:10 chenjiahan

📝 Ran ecosystem CI: Open

suite result
modernjs :white_check_mark: success
rspress :white_check_mark: success
rslib :x: failure
rsbuild :white_check_mark: success
examples :white_check_mark: success
devserver :white_check_mark: success

rspack-bot avatar Oct 11 '24 13:10 rspack-bot

@JSerFeng can we merge this

sure, I'll approve once this is not draft

JSerFeng avatar Oct 14 '24 06:10 JSerFeng

🎉

chenjiahan avatar Oct 18 '24 05:10 chenjiahan