-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Describe the bug
I'm updating @swc/core from 1.3.95 to 1.13.1 and found performance regression when plugins used.
I have prepared a repository for reproductions
https://github.com/MemeBattle/swc-perf-platf/tree/main
steps:
npm run install:deps
- ./benchmark_all.sh
This script will:
Run all four build variants (old (1.3.95)/new(1.13.1) × with_plugin/without_plugin) three times each
My results: (Apple M3 Pro 12 cores)
==== old without_plugin ====
Run 1: 13 s
Run 2: 13 s
Run 3: 12 s
Average time for old without_plugin: 12.66 s
==== old with_plugin ====
Run 1: 16 s
Run 2: 16 s
Run 3: 15 s
Average time for old with_plugin: 15.66 s
==== new without_plugin ====
Run 1: 9 s
Run 2: 8 s
Run 3: 8 s
Average time for new without_plugin: 8.33 s
==== new with_plugin ====
Run 1: 25 s
Run 2: 23 s
Run 3: 23 s
Average time for new with_plugin: 23.66 s
==== Summary (average time, s) ====
Version Plugin Average
old without_plugin 12.66
old with_plugin 15.66
new without_plugin 8.33
new with_plugin 23.66
==== Plugin slowdown ====
Old version: x1.23 (with_plugin is 1.23 times slower)
New version: x2.84 (with_plugin is 2.84 times slower)
==== New vs Old (without_plugin) ====
New version is 1.51 times faster than old (without_plugin)/
CI results (2 physical cores 4 logical, linux x64)
==== old without_plugin ====
Run 1: 42 s
Run 2: 42 s
Run 3: 41 s
Average time for old without_plugin: 41.66 s
==== old with_plugin ====
Run 1: 56 s
Run 2: 56 s
Run 3: 56 s
Average time for old with_plugin: 56.00 s
==== new without_plugin ====
Run 1: 31 s
Run 2: 31 s
Run 3: 31 s
Average time for new without_plugin: 31.00 s
==== new with_plugin ====
Run 1: 54 s
Run 2: 54 s
Run 3: 54 s
Average time for new with_plugin: 54.00 s
==== Summary (average time, s) ====
Version Plugin Average
old without_plugin 41.66
old with_plugin 56.00
new without_plugin 31.00
new with_plugin 54.00
==== Plugin slowdown ====
Old version: x1.34 (with_plugin is 1.34 times slower)
New version: x1.74 (with_plugin is 1.74 times slower)
==== New vs Old (without_plugin) ====
New version is 1.34 times faster than old (without_plugin)
As a result, the new version is faster without plugins than the old one.
But when plugins used, the performance degrades much more than before.
As a result, the overall build time becomes longer
I'm not sure, but I think there is another reason that affects the results. Maybe it's the number CPU cores or arch.
Because on our project with webpack+swc-loader on my machine I have similar time with plugins and new swc/core like before. But CI (on x64) is slower on ~20-30%
Also I don't get why on github runner difference not so big
Link to the code that reproduces this issue
https://github.com/MemeBattle/swc-perf-platf/tree/main
Expected behavior
Enabling plugins with the new core does not destroy performance
Actual behavior
New @swc/core with plugins slower than old @swc/core with plugins
Version
1.13.1