-
Notifications
You must be signed in to change notification settings - Fork 66
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
Consider using compileStreaming
and instantiateStreaming
to enable WASM caching on Node
#363
Comments
The |
compileStreaming
and instantiateStreaming
to enable WASM cachingcompileStreaming
and instantiateStreaming
to enable WASM caching on Node
I think it only does that on non-Node platforms though? This chunk seems to branch do the the non-streaming jco/crates/js-component-bindgen/src/intrinsics.rs Lines 136 to 139 in c6e16b0
Realized that was not really specified in the issue title so edited that in. |
Yes, but Node.js doesn't have any network cache to share the Wasm compilation like browsers do, which is the layer at which this behaves anyway. If Node.js did support that we could certainly revisit this. |
Ahh that is unfortunate, well appreciate the explanation and will close this out |
According to this V8 blog post (which is from 2019 so might be out of date, but I couldn't find anything newer), WASM modules are only cached when using the
compileStreaming
andinstantiateStreaming
APIs. Both of these are supported by Node (implementation PR). Although MDN says Node doesn't supportcompileStreaming
, I have tested it and it exists and works as expected. Switching to these, and ideally just usinginstantiateStreaming
seems like it could provide substantial performance improvements in cases where users need multiple instances of the same module, or by allowing for the instantiation of modules inWorker
threads.The
*Streaming
APIs expect theResponse
type return of afetch
call, unfortunately Node'sfetch
doesn't seem to support getting local files yet. Thankfully it is possible to manually construct aResponse
object with aContent-Type: application/wasm
header that is accepted by the APIs.The text was updated successfully, but these errors were encountered: