-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
esbuild-wasm
on Windows with Node.js v14 and an ESM loader enabled takes a while to load
#2888
Comments
It sounds like you're saying that node has a performance issue with WebAssembly + Windows + ESM loaders. I believe you, but I don't know what I can do about it. Should this be a bug report for node instead? In the meantime, you could consider using esbuild's native API instead of the WebAssembly API, especially if you are interested in higher performance. The native API should be significantly faster. And for maximum speed you could also consider not using the
I'm guessing you're trying to use esbuild to implement a TypeScript ESM loader. But you could also consider bundling everything together with esbuild and then running it as an alternative if the loader stuff is getting in the way. Here's the code I used to generate the above output (run it using
|
Yeah, it might be that, I opened an issue here first in case it was an issue with how the "glue code" interacts with Node.js v14 on Windows.
Yeah, but that's unrelated in this case, the reproduction doesn't involve Yarn.
Not really, I'm replacing our use of
While that might speed up running Yarn from sources it would prevent us from dogfooding the PnP hook. |
After looking into it a bit more it seems to boil down to nodejs/node#36616 as I can reproduce the issue with the following script: const data = require('fs').readFileSync('node_modules/esbuild-wasm/esbuild.wasm');
console.time('instantiate');
new WebAssembly.Module(data);
console.timeEnd('instantiate'); Node.js v14.21.2: $ time node test.js
instantiate: 139.521ms
________________________________________________________
Executed in 50.40 secs fish external
usr time 0.00 millis 0.00 millis 0.00 micros
sys time 16.00 millis 16.00 millis 0.00 micros Node.js v16.19.0: $ time node test.js
instantiate: 142.864ms
________________________________________________________
Executed in 4.77 secs fish external
usr time 15.00 millis 0.00 micros 15.00 millis
sys time 15.00 millis 0.00 micros 15.00 millis Node.js v18.14.0: $ time node test.js
instantiate: 125.414ms
________________________________________________________
Executed in 234.44 millis fish external
usr time 0.00 millis 0.00 micros 0.00 millis
sys time 15.00 millis 0.00 micros 15.00 millis If I add It's interesting that in the original reproduction a |
Describe the bug
Running
esbuild-wasm@0.17.5
on Windows with Node.js v14.21.2 and an ESM loader enabled takes a long time to return on the first transform call.Ref yarnpkg/berry#5180 (yarnpkg/berry@79ce8bd)
To Reproduce
Run the following script
Expected behaviour
When the
--loader
flag isn't specified:Actual behaviour
When the
--loader
flag is specified:Additional information
Adding
--prof
to the node flags atnode_modules/esbuild-wasm/lib/main.js:1927
and processing the isolate log withnode --prof-process
gives the following output:The text was updated successfully, but these errors were encountered: