Hacker News new | ask | show | jobs
by macguillicuddy 409 days ago
We do high performance computer vision in the browser (at 30/60 fps) that's an order of magnitude faster in WASM than JS. It simply would not be fast enough without WASM.
2 comments

Interesting. Really an order of magnitude?

What types of operations are 10x faster in Wasm than in JS? Why can't the JIT compiler compile JS to the same native code as your Wasm gets compiled to?

We have tight inner loops over large numbers of pixels - in some cases optimized to the level of careful register choice and SIMD
Basically everything numerical. I have similar experience, translated some JS code to wasm - simple template matching algorithm, basically doing the same thing (looping over ArrayBuffer and computing some sums) and it was 10x faster.
You could offload to WebGL/WebGPU for that.
We do for some elements of our pipeline. WebGPU will give us more opporunity for this in the future too but right now we need broader device support unfortunately.
Sure, but that's much more complex to implement, and comes with its own overhead.
Not that WASM tooling is such an example of great developer experience.
It's much easier to integrate some Wasm than it is to rearchitect your software to run on a GPU.
Or you could use Wasm
WASM is slower, and the toolchain sucks for most languages.
Why does "most" matter in this case wnen you just need 1 that suits your needs?
> WASM is slower […]

Without more details on their exact use case, their algorithms, and their data movement patterns, you have no way of knowing this. Doing stuff on the GPU isn't automatically faster than doing it on the CPU.