WASM support on V8 runtime / node.js
Hi, I tried to find the information but couldn’t get it right.
Does the V8 runtime support WASM files, because I don’t see WebAssembly in the list of supported APIs.
Same question for node.js runtime (I prefer to use V8 runtime as it is more efficient)
Thanks !
9 Replies
Hi! Yes WebAssembly is supported by both the convex (v8) runtime and the node.js runtime. You can do the compiling yourself (throwback to https://www.youtube.com/live/Hy2n2vpvZH8?si=eJKO6ZTJVlQoMoDy ) which is probably not what you want. Or you can import .wasm files as if they were javascript. For node you should be able to do the same, and as an additional escape hatch it can install packages on the server to support more configurations https://docs.convex.dev/functions/bundling#external-packages
We haven't exhaustively tested wasm in Convex, so please let us know how it goes
Thomas Ballinger
YouTube
WebAssembly in the Cloud with Convex
WebAssembly in the cloud! Let's keep working on this manygolf clone with Convex, but try to do something wacky: could we write our ball simulation code in Ru...
Bundling | Convex Developer Hub
Bundling is the process of gathering, optimizing and transpiling the JS/TS
Thanks for your answer.
I did some experiments on V8 runtime and I can say it is partly working.
I used glue code generated using wasm-pack (target web, I tried with target bundler and didn’t work saying is malloc is undefined).
First thing: I binded console.log to use it in Rust but all my log statements in the console appears as « undefined », when I test the same glue code locally on chrome every log statements are fine.
I got big discrepancies concerning running times, from 1299ms to 6650ms, for the same input.
Away of that, the actual rust code seems to work great, but not having console output is a pretty big downside.
@theodm while WebAssembly APIs are supported in Convex there are some known issues with the way we bundle wasm-pack generated glue code: currently the Convex CLI configures esbuild to import .wasm files as uninstantiated modules instead of the weback-style
asyncWebAssembly
approach (which wasm-pack glue expects)
We could add an experimental option to use https://github.com/Tschrock/esbuild-plugin-wasm to handle wasm files instead which when in my tests has made everything work correctly. I'll let you know when we have this in, it hasn't been a priority because we have few customers using wasm-pack so it's great to hear this is something you'd like to use.
I got big discrepancies concerning running times, from 1299ms to 6650ms, for the same input.Is this comparing wasm to JavaScript? 6650ms is pretty wild, would love to get a repro for this
I can confirm it is a bug in the building process of the glue code.
wasm-bindgen generate the following glue code: which make log statements undefined in convex dashboard.
But replacing to makes log statements ok.
esbuild-plugin-wasm could be a great addon, otherwise I will edit my own glue code.
Concerning running time, I was speaking about the one we can see from convex dashboard (the global function running time), did some new tests this morning and all were under 1000ms. The actual rust code take 52ms to execute from wasm in all run but the action that take the most time is
let file = await request.arrayBuffer();
which took between 500ms to 800ms depending on runs, that body is in fact a 4MB binary file so not a very big one.
That might be due to the client latency to send the whole file to the server ? Depending on the location of the servers, that seems pretty big to me: I am testing from Paris, France using a 1 Gbps connection.Hi, I want to use wasm in order to use Post Quantum Encryption algorithm libraries with Convex.
Have the issues that have been discussed here been resolved?
(All TS post quantum libraries are shit)
I want to use a library like: https://github.com/open-quantum-safe/liboqs
GitHub
GitHub - open-quantum-safe/liboqs: C library for prototyping and ex...
C library for prototyping and experimenting with quantum-resistant cryptography - open-quantum-safe/liboqs
(Not related to your question, but I have it on good authority that you don't need to worry about quantum computers 😄 )
wdym? it is mostly a research project so I can show my friends and literally everyone that I have an chat app that is as safe as Signal and iMessage, but would be cool to know how stable WASM in the convex runtime is. (just for the flex and the stuff I will learn down the way)
otherwise I have to use node for that
also organisations like the NSA are accused of storing messages to decrypt them if they have a powerful enough quantum computer
but would be cool if you tell more about what you know
(I basically have a friend who works at the forefront of Quantum Computers, so I'm judging based on his understanding of where the tech is)