| ▲ | theultdev 6 hours ago | |||||||||||||||||||||||||||||||||||||||||||
Sad day. I have a sha256 hasher in asm.js that's faster than any wasm solution. | ||||||||||||||||||||||||||||||||||||||||||||
| ▲ | bvisness 5 hours ago | parent | next [-] | |||||||||||||||||||||||||||||||||||||||||||
In SpiderMonkey, asm.js code has been compiled by exactly the same pipeline as wasm since at least 2019. In fact, the way we compile it is literally to construct a pseudo-wasm module and run it through our wasm compiler (with a few flags to tweak the behavior to fit the asm.js semantics). In other words, if you're running asm.js in Firefox, you're literally just running wasm anyway, so how could it possibly be faster? Furthermore, if you use wasm, you'll have fewer bounds checks (because of better memory allocation strategies[1]), access to SIMD, bulk memory operations, and a host of other niceties that have been added to wasm over the years. If your asm.js code is outperforming someone else's wasm code, that probably just means their wasm code is worse. [1]: https://spidermonkey.dev/blog/2025/01/15/is-memory64-actuall... | ||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||
| ▲ | lukan 6 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||
That is surprising. Do you know the reasons? Is it a special use case or was asm really faster? I find that hard to believe. | ||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||
| ▲ | theultdev 3 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||
Made the requested benchmark: https://theultdev.github.io/web-sha256-benchmark https://github.com/TheUltDev/web-sha256-benchmark It's Chrome wasm (windows) that is slow for me, 2x slower than asmjs. FF with asmjs optimizations are 2x slower than wasm on FF. Wasm in FF is 2x faster than wasm in Chrome for this hashing solution (for me). | ||||||||||||||||||||||||||||||||||||||||||||
| ▲ | dist-epoch 5 hours ago | parent | prev [-] | |||||||||||||||||||||||||||||||||||||||||||
what's wrong with the built in one? https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypt... | ||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||