Hello,
Is there anywhere I could read more about the AOT JavaScript compilation mentioned in this article from last year: https://bytecodealliance.org/articles/making-javascript-run-fast-on-webassembly
In combination with the fast instantiation coming in Wasmtime 1.0 it would seem quite compelling.
Thanks!
When I spoke with @Saúl Cabrera about this a few weeks ago, he estimated that about 1000 hours of work are needed to make SpiderMonkey AOT usable. I'm not sure if anyone has actually been working on it lately, though.
In the meantime, we've been seeing good FaaS performance with the combination of QuickJS + Wizer + Wasmtime that Javy uses. It won't give you the same kind of throughput for CPU-heavy workloads as AOT compilation, but it's great for fast instantiation and I/O-bound workloads.
Many thanks for pointing me to Javy.
I experimented with using React renderToString on a moderately complex page from a real app (30KB html rendered.) Timings are just for the renderToString on my MacBook Air M1.
Deno first iteration: 12-20ms
Deno subsequent iterations: 2-4ms
qjs: 18-24ms
javy: 40-60ms
AOT would make a substantial difference but his definitely opens up a lot of possibilities.
I guess running something like Deno in Firecracker is probably faster for this use case for now (they claim a 3-7ms snapshot restore time) but it's more tricky to develop since there's no nested virtualization on M1 Macs or EC2 (though it does work on GCP and Github Codespaces.)
Anyone compiling quickjs from shopify? I forked the toolchain on javy and enabled file imports. I'm now at a point where im trying to support nodejs apis to make them run in wasm/wasi but it seems like a really daunting task because of the number of libraries. Has anyone encountered this and how did they go about it if you don't mind me asking
We're using Javy's quickjs-wasm-rs
crate in our experimental Spin JS SDK project. So far, we've only implemented a couple of NodeJS APIs, namely fs.readFile and fs.readdir which primarily defer to Rust code for the implementations. The Rust code also populates process.env
with any variables in the WASI environment.
We also provide a minimal fetch
API, Math.random()
, etc.
Not sure what your end goal is, but I would recommend adding host APIs (e.g. NodeJS-style or Web API) as you encounter the need for them (e.g. libraries that depend on them) rather than try to tackle them all at once.
Last updated: Dec 23 2024 at 12:05 UTC