Hacker News new | past | comments | ask | show | jobs | submit login

Just days ago I was rewriting some matrix math operations for our game from C to WASM SIMD, only for most of them to barely tie the original performance (where for reference a crappy x86 SIMD routine gives me 3x to 5x).

That's not something you'd use for "computationally intensive" applications. Frankly this shit has been around for years and the major implementations still suck.

As for servers, it's insane to pretend you don't know what your server's CPU is and run your crap in what's essentially a handicapped JVM. Made up solutions for made up problems.




The problem with just moving hot routines over to Wasm is that you pay overhead every time you cross the Wasm boundary. The success stories I’ve heard with Wasm typically involve writing the entire computational core and renderer in Wasm, to minimize the amount that the boundary is crossed.

Here’s an example of an architecture that seems to work well: https://x.com/paulgb/status/1688919428740816896?s=46


We don't jump a WASM/JS boundry, the entire game is written in C/C++ - we only jump to JS once at the end of each game frame when it comes time to render, so we do all WebGL calls from JS at once.

What I did was rewrite a chunk of our matrix math library, previously written in C, directly into WASM with the shiny new SIMD operations.

Rewriting a naive 4x4 matrix multiplication with SIMD gains you 3x to 4x on on x86 (with the algorithm from the answer in [1]), and a direct translation of that using the WASM SIMD instructions gains you nothing on Chrome.

On Firefox the WASM SIMD is 20-30% faster than naive multiplication, which is not much, but it's something. The issue is that on Chrome the WASM version is dead even with the scalar implementation, and to be honest I care a lot more about performance on Chrome than on Firefox.

[1] https://codereview.stackexchange.com/questions/101144/simd-m...


> the entire game is written in C

My apologies, that was clear from your original post but I misread it as saying you were porting into C to use SIMD in Wasm.

Thanks for the stats, that's good data to know.


The experience is worse than Java, .NET and BEAM application servers, while pretenting to have invented something new.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: