
Improving DataView performance in V8 - ingve
https://v8project.blogspot.com/2018/09/dataview.html
======
aappleby
I'm one of the Google Maps developers that worked on the typed-array version
of the loading code - hooray for DataView finally being a viable alternative.
:)

------
tokyodude
This is great. Let's hope they plan to also update TypedArray support in
general.

NativeArrays are still like 2x faster than Float32Arrays for matrix math.
Probably has to be that way ATM as the math has to be promoted to double and
back?

Still, v8 seems to be about 2x slower than SpiderMonkey in this area

[http://greggman.github.io/webgl-matrix-
benchmarks/matrix_ben...](http://greggman.github.io/webgl-matrix-
benchmarks/matrix_benchmark.html)

------
saagarjha
It seems from the code snippets that DataViews are strongly typed. So what
happens when you load data with the wrong type? Does JavaScript have
"undefined behavior"?

~~~
aappleby
It's just a blob of bytes. If you write a 32-bit float and then read an int
from the same location, you get whatever int those 32 bits form.

~~~
Waterluvian
That generally tells me that this tool is meant for developers smarter than me
to make the appropriate abstractions for me to use. Not for me to consider
this a core part of my web app development toolkit. :)

~~~
Ajedi32
Very much in keeping with the [Extensible Web Manifesto][1].

[1]:
[https://extensiblewebmanifesto.org/](https://extensiblewebmanifesto.org/)

------
kbumsik
Great article. I didn't know DataView was much slower than TypedArrays. I
always prefer DataView over TypedArrays when writing protocols and file
formats, because TypedArrays follows system endianness so you cannot set
endianness manually. (It is true that big-endian CPU is very rare but I cannot
stop worrying about endianness.)

------
adzm
> we also removed support for indices or offsets that are too large (outside
> of Smi range) inside the TurboFan-optimized code

What exactly is Smi range? I have a feeling it is something obvious that I'm
overlooking.

~~~
ryanpetrich
In V8, small machine integers are signed 31bit integers on 32bit architectures
and signed 32bit integers on 64bit architectures.

