9 ms·
> the speed is close to native The numbers I seen suggest wasm is 3-5x slower then native which isn't bad IMO. JavaScript is also 3-5x slower than native. Is J
by ArrayBoundCheck 4y ago
> the speed is close to native
The numbers I seen suggest wasm is 3-5x slower then native which isn't bad IMO. JavaScript is also 3-5x slower than native. Is JS close to native speed? I don't think you can say it about one but not the other
- azakai 4y agoThat estimate is way off. Wasm overhead is somewhere in the range of 50% (1.5x slower) to 14% (1.14x slower). Sources: * https://www.usenix.org/system/files/atc19-jangda.pdf https://www.usenix.org/system/files/atc19-jangda.pdf * https://kripken.github.io/blog/wasm/2020/07/27/wasmboxc.html https://kripken.github.io/blog/wasm/2020/07/27/wasmboxc.html It is true you can find a specific benchmark where wasm is 3-5x slower, say if the original uses highly-tuned x86 SIMD or relaxed atomics (or if the wasm version has SIMD or threads turned off entirely). But in general, the overhead is much lower.
- ArrayBoundCheck 4y agoI'm not sure which implementation browsers use but only one engine wasn't on average < 3x slower https://medium.com/wasmer/benchmarking-webassembly-runtimes-18497ce0d76e https://medium.com/wasmer/benchmarking-webassembly-runtimes-...
- azakai 4y ago(As I said in another comment, those are 4 microbenchmarks. The links I provided contain both real-world codebases and also large sets of varied benchmarks.)
- ArrayBoundCheck 4y agoVaried? You're joking they're all math This guy found sqlite to be 19x slower. https://ricomariani.medium.com/wasm-sqlite-for-web-products-a86bb172f8ab https://ricomariani.medium.com/wasm-sqlite-for-web-products-...
- SotCodeLaureate 4y ago> sqlite ... 19x slower But is this a failing of wasm or the system glue layer, that for something like sqlite/web has to go through js/browser/etc? Yes, I understand the importance of real-life tests like this, but how one is expected to go about testing wasm performance as such other than using benchmarks that are mostly arithmetic/logic and not syscall-type code?
- ArrayBoundCheck 4y agoHow you use it in real life has to be taken in consideration. From memory system like calls go through JS and there's no realloc. I didn't want to say it in my first comment because I notice the more someone writes the more likely others will argue. I rather someone else post the SQL benchmark but apparently everyone drank the kool aid and had no idea wasm isn't that fast. I certainly would rather use JS than write c++/rust. I wouldn't be surprised if that list of companies using wasm only use it for one or two large projects then stuck to js because of how much work wasm is
- azakai 4y agoSQLite is one of the many benchmarks covered in one of my 2 links. The slowdown there is just under 50%. (SQLite stresses not just wasm but also other Web APIs, like storage, which might explain different results in different types of benchmarks.)
- ArrayBoundCheck 4y agoCuriosity is getting to me. Why on earth would you use wasm outside of a browser instead of a container like most people? When you said I was wrong I knew right away you either never actually tested or you're talking about outside of the browser. If it wasn't clear I was talking about wasm in chrome/safari/firefox this entire time
- azakai 4y ago> When you said I was wrong I knew right away you either never actually tested or you're talking about outside of the browser. No, I actually was talking about the browser. And I have actually tested. You'll find my name on a bunch of public benchmark results about wasm and its predecessor asm.js, all in a Web context, * Various benchmark posts on Mozilla Hacks: https://hacks.mozilla.org/author/azakaimozilla-com/ https://hacks.mozilla.org/author/azakaimozilla-com/ * The original wasm paper: https://people.mpi-sws.org/~rossberg/papers/Haas,%20Rossberg,%20Schuff,%20Titzer,%20Gohman,%20Wagner,%20Zakai,%20Bastien,%20Holman%20-%20Bringing%20the%20Web%20up%20to%20Speed%20with%20WebAssembly.pdf https://people.mpi-sws.org/~rossberg/papers/Haas,%20Rossberg... * The WasmBoxC post: https://kripken.github.io/blog/wasm/2020/07/27/wasmboxc.html https://kripken.github.io/blog/wasm/2020/07/27/wasmboxc.html And specifically SQLite is a benchmark that I've looked at many times over the years. It's an important codebase. That's why I added it to the Emscripten benchmark suite, and why it is measured in that last link. (Fyi, I am one of the co-creators of WebAssembly, I created Emscripten, and I have been working in the compile-stuff-to-the-Web space for over a decade.)
- SotCodeLaureate 4y ago> if the original uses highly-tuned x86 SIMD BTW, if there is a problem with the current WASM performance, it's probably SIMD. Again, based solely on my own benchmarks, exclusively in the area I'm interested in (game-type workload, so, say, multiplying many small matrices, performing geometric tests), there is little to no speed-up from wasm-simd128 (where it is supported), whereas native code compiled from the same sources, by the same compiler, profiled on the same machine, seems to be running a bit faster when vectorized.
- Kranar 4y agoThe numbers you've seen suggest you're making things up.
- ArrayBoundCheck 4y agoWhy did mods delete the post with the link showing this commenter is the one in fact making things up?
- deleted 4y ago[deleted]
- ArrayBoundCheck 4y ago
- azakai 4y agoThose are 4 microbenchmarks. There are much larger and more realistic workloads benchmarked in other places (see https://news.ycombinator.com/item?id=32084768 https://news.ycombinator.com/item?id=32084768 for links), with very different results.
- ArrayBoundCheck 4y ago
- SotCodeLaureate 4y ago> 3-5x slower than native Depends on workload of course, but seems too pessimistic with the current state of WASM support. At least this is not what I'm seeing with the things I'm working on (graphics-related), when comparing to native builds. See this test for example, native seems to be only 50% faster: https://old.reddit.com/r/WebAssembly/comments/vjxtv4/webassembly_speed_on_gametype_workload/ https://old.reddit.com/r/WebAssembly/comments/vjxtv4/webasse...
- cdelsolar 4y agoI have run benchmarks directly with the actual codebase running on my computer and then the WASM version and the WASM is about 70-80% of the speed. Sadly, when the analyzer was written in Go, I was getting around 20-25% of the speed after compiling to WASM. I believe it is largely due to that code being very inefficient about allocations, and I think WASM doesn't like allocations/deallocations very much.