News for hackers. Stuff that matters.
Re:Faster TypedArrays: Vector Addition in WebAssembly by Matheus28 on Sunday January 02, 2022 @01:08PM (#29771589)
If we're not counting the time to zero out the array, it seems that typed arrays are slower than plain javascript because it's converting to & from floats/doubles back and forth. Try the same with Float64Array. My microbenchmark says f32 is 15% slower than f64 on chrome: https://jsbench.me/gnkxxkjag8/1
Re:Faster TypedArrays: Vector Addition in WebAssembly by greggman3 on Sunday January 02, 2022 @01:40PM (#29772007)
And as usual for me, JavaScriptCore blows away V8 in most microbenchmarks I've run

Same machine, JSC (Safari) is 3x faster than Chrome https://jsbenchit.org/?src=c792550e65de1d038b1f24b446c74592

Re:Faster TypedArrays: Vector Addition in WebAssembly by brrrrrm on Sunday January 02, 2022 @01:31PM (#29771900)
Great catch! I assumed the JIT would identify f32 arithmetic but I guess that isn't really valid numerically. I wonder if there's a way to use Math.fround[1] on your benchmark to get expected speedups?

[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Re:Faster TypedArrays: Vector Addition in WebAssembly by olliej on Sunday January 02, 2022 @02:46PM (#29772904)
Yup, the spec requires computation to be as doubles and so any computation must be done that way as the end result is observable.

I didn’t know about fround but I suspect its primary use case is for trying to catch floating point overflow during double arithmetic, because again precision difference is observable.