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

Why Object of Arrays beat interleaved arrays: a JavaScript performance issue

https://www.royalbhati.com/posts/js-array-vs-typedarray
loading story #46666201
loading story #46666589
loading story #46666189
loading story #46665039
loading story #46708638
loading story #46670118
Running the benchmark from the article on my laptop (M4 Macbook Air) had a few interesting results:

* when running the script with Node.js, the results are inline with the article (SoA is the fastest)

* Bun is slower than Node.js with both SoA and AoS.

* Bun has similar performance between SoA and AoS.

* in Bun, Interleaved is the fastest one by a significant margin. This is consistent through runs.

% bun bench.js

AoS: 924.54ms

SoA: 1148.57ms

Interleaved: 759.01ms

Bun's performance profile seems very different from Firefox and V8-based runtimes there. I wonder how QuickJS would fare. The article didn't mention the CPU used either, the performance difference may be dependent on the architecture as well.

loading story #46669642
loading story #46664911
loading story #46664805