Performance of WASM-based Plugins #7521
-
I have written a SWC plugin that is compiled into WebAssembly and then configured as (SWC) plugin from an NodeJs application. The performance is currently behind the expectations we had. The Babel version is about twice as fast (but consumes four time as much memory). Did you have a similar experience? Is there also a way to write "native" SWC plugins? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
Some more details: I am processing files that are in the range of megabytes, for example, adding coverage similar to the swc-plugin-coverage-instrument plugin. |
Beta Was this translation helpful? Give feedback.
-
No for both. First, if you run swc-coverage-instrument test case itself, wasm plugin vs native transform performs nearly similar. When we measured back in the day we expects wasm plugin performs roughly 70-90% to the native codes at the best perf, depends on what it performs underlying. There is no such thing like native plugin. There was an experiments around those before introducing wasm plugin, but we dropped those idea due to it makes nearly impossible to plugin author to provide binaries for the each targeting platform. The only way is you build your own custom variant of swc as same as next.js does. |
Beta Was this translation helpful? Give feedback.
-
Can you profile it? |
Beta Was this translation helpful? Give feedback.
-
If you can find bottleneck specific to swc, happy to look into it though. |
Beta Was this translation helpful? Give feedback.
-
Hi. The WASM transpilation does not seem to be the problem (I would guess). Running the |
Beta Was this translation helpful? Give feedback.
No for both. First, if you run swc-coverage-instrument test case itself, wasm plugin vs native transform performs nearly similar. When we measured back in the day we expects wasm plugin performs roughly 70-90% to the native codes at the best perf, depends on what it performs underlying.
There is no such thing like native plugin. There was an experiments around those before introducing wasm plugin, but we dropped those idea due to it makes nearly impossible to plugin author to provide binaries for the each targeting platform. The only way is you build your own custom variant of swc as same as next.js does.