perf: cache swc loader
Summary
Checklist
Assume:
- Creating an
SwcLoaderJsOptionsis costly - Most modules are created with same swc loader options
Cost:
RwLockand 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).
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 |
!bench
📝 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 % |
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 can we merge this
!eco-ci
📝 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 |
@JSerFeng can we merge this
sure, I'll approve once this is not draft
🎉