DataView two orders of magnitudes slower in Firefox

1 points by mschuetz ↗ HN
Try this in Firefox and Chrome: https://jsperf.com/dataview-float-int

This is a pretty long standing issue with a significant impact on the performance of real-time rendering in web browsers. Loading 3D models or transforming/processing buffers often requires the functionality provided by DataView. In Chrome, reading and summing up 10 million floating point values takes around 7 milliseconds with DataView. The same task takes around 280 milliseconds in Firefox - 40 times longer.

A widely used hack is to read the 4 bytes of a float value from the source buffer and write them into a temporary Uint8Array. Then, read the result from a Float32Array that points to the underlying ArrayBuffer. This hack is about as fast in Firefox as it is in Chrome -> 10 times slower than DataView in Chrome, ~4 times faster than DataView in Firefox.

With WebGPU coming up, this is something that should probably be taken so as not to fall behind Chrome for applications that use a standard API that is significantly faster than the workaround.

0 comments

[ 4.9 ms ] story [ 8.4 ms ] thread

No comments yet.