Ask HN: WebAssembly JavaScript Overhead?

2 points by dakom ↗ HN
Is there some good data about the overhead in JS<->WebGL communication?

Specifically, I'm interested in using JS to handle the view (whether WebGL or DOM) and as like a broker between worker threads, as well as general gluey things and simple app logic - and WebAssembly for some heavy lifting and number crunching.

Not sure _exactly_ where the balance of all that would land - but I am curious about the overhead of passing messages between the JS and WebAssembly layers, so that I can consider things a bit more carefully.

To pre-empt some answers - I do get that it might make more sense to split that balance more heavily one way or the other, but at this point I'm just wondering about hard data on what the communication costs.

Thanks!

1 comment

[ 3.1 ms ] story [ 9.6 ms ] thread
I recently experimented with this [0] - there is some overhead but it's acceptable. I noticed that the more arguments you pass over into a Wasm function, the slower things get (see .set test).

Note: I'm either bad at doing correct benchmarks or the Javascript compiler is pretty sneaky at optimizing things.

[0] - https://maierfelix.github.io/glmw/mat4/