4 ms·
One thing is pure call performance (time to invoke a void() function). I don't know where that is, but I guess for WASM<->JS it's slower than WASM<->WASM and JS
by Matthias247 9y ago
One thing is pure call performance (time to invoke a void() function). I don't know where that is, but I guess for WASM<->JS it's slower than WASM<->WASM and JS<->JS, since it can't be inlined.
The more important thing however is the cost of parameter passing. Let's keep in mind that WASM only support numeric types and typed arrays. So in order to make a function call from JS to WASM or the other way around which passes a string as a parameter the string needs to be converted into a format that the other side understands (Javascript string object <-> WASM typed array which contains string in UTFx format).
So basically for all more complex data types crossing the boundary costs the [de]serialization of the parameters, which may be huge (and even causes allocations).
If you also only work with integers and typed arrays on the JS side that does not apply. But I guess most people won't be comfortable with that.
- gsnedders 9y ago> One thing is pure call performance (time to invoke a void() function). I don't know where that is, but I guess for WASM<->JS it's slower than WASM<->WASM and JS<->JS, since it can't be inlined. …why can't it be inlined? There's no good reason why it can't be inlined.
- Matthias247 9y agoWhen I wrote about that I thought about static resolving of where inlining is possible, which would be hard on a boundary to a dynamic language. But yeah, assuming both WASM and JS run inside the same JITting VM it is probably happening.