3 ms·
Why WASM can't give native performance?? (games in a browser?). All demos I saw only gives 8-10x performance boost?? (with respect to JS)
by tandav 9y ago
Why WASM can't give native performance?? (games in a browser?).
All demos I saw only gives 8-10x performance boost?? (with respect to JS)
- steveklabnik 9y ago> Why WASM can't give native performance? As with any language, it depends on how good the optimizations are; wasm is designed to be able to be JITted fast, but is still fairly new, so there's still stuff left on the table. Additionally if you're compiling a language to wasm, you're also at the mercy of that compiler as well, so it always depends. > only 8-10x performance boost I'll take it ;)
- tmzt 9y ago> Additionally if you're compiling a language to wasm, you're also at the mercy of that compiler as well, so it always depends. and potentially runtime, depending on the language you are compiling from
- dangerbird2 9y agoMost wasm toolchains use clang for c/c++, so poor compiler generation is rarely a significant issue. IIRC, the emscripten toolchain uses musl as the C runtime, which is reasonably performant runtime. Of course, if you write algorithmically inefficient code, no toolchain is going to improve it.
- flohofwoe 9y agoWASM currently doesn't support SIMD and threading, other than that it is already close to single-threaded native performance (usually within 1.2x to 1.5x, there are some runtime checks happening after all). Frankly, I would be surprised to see well-written Javascript code that's consistently 8x to 10x slower than (single-threaded, non-SIMD) native performance. You have spikes from GC and re-compilation, but JITed JS is not that slow.
- dangerbird2 9y agoWASM is not native code, so there's no guarantee it will have the same performance. There have been earlier attempts to have cross-browser and cross-platform native code execution on the web, not to mention plenty of nonportable web plugins, but WASM's just-in-time compilation of a low-level bytecode is a good balance between performance across different architectures and feasibility of sandboxing code execution (you don't want a web app to gain access to your filesystem and kernel syscalls with impunity)