Closed Bug 650657 Opened 13 years ago Closed 5 years ago

Improvements to typed arrays [meta]


(Core :: JavaScript Engine, defect)

Not set





(Reporter: gal, Unassigned)



(Keywords: meta)

A number of improvements should be done to the typed array code. Most of these could be independent bugs:
- Typed arrays store their state in a struct allocated with malloc. Use inline slots instead since we have larger object headers now.
- Typed arrays allocate a separate buffer (separate JS object, 2nd malloc for struct) to store data, but the most frequent use case are small typed arrays. Instead, we should implement typed arrays that store data inline in slots (for small typed arrays a header would even suffice) and if anyone gets the buffer (rare), we make the buffer share a concrete typed array's data.
- Eliminate typed array finalizers (expensive, unnecessary if we use slots).
- All of the above will affect JITs and needs to be optimized.
> the most frequent use case are small typed arrays

Do we have data to back this up?  Seems like most of the things I've seen using typed arrays (ImageData processing, Alon's C-to-JS compiler, emulators, audio data, XHR) have pretty large typed arrays...
When last I looked at this stuff there were a lot of vectors and small matrices for the various 3D/WebGL pieces, but I don't know if we gathered broad-spectrum data on it.
Ah, yes.  I can see how the WebGL uses would primarily be small arrays.  I guess I've mostly seen the non-WebGL uses (abuses?) of this stuff.
Depends on: 656519
Depends on: 677854
No longer depends on: 677854
FireFox Nightly 10.0a1 (2011-11-03) performance is 50% slower than Chrome 17 in  WebGL Matrix LIbrary Benchmarks testing.

If instead I compare the average results of the top two performing webgl matrix libraries on each platform FireFox Nightly 10.0a1 is more than 60% slower than Chrome 17.

I've updated my benchmark page comparing matrix libraries useful for webgl programming with newer versions of some of the libraries:

- closure to svn rev: 1364
- glMatrix to 1.0.1
- tdl to commit: 59d484f, Fri Jun 3 2011

Benchmark page:


The best performing libraries on Chrome 17 and FF Nightly 10.0a1 are Closure and the TDLFast version of the TDL library.

On Safari Nightly 5.1.1 (6534.51.22, r98912) the situation is reversed and the fastest library is CanvasMatrix. CanvasMatrix is one of the slowest on the other browsers (I'm a bit suspicious about the results I am getting in the Transpose test with CanvasMatrix ???).

Average for tests in millions of operations/s

                                         all tests   top two performing tests                                      
Chrome 17.0.928.0 canary                   19.4          28.4
FireFox Nightly 10.0a1 (2011-11-03)         8.4          10.9
Safari Nightly 5.1.1 (6534.51.22, r98912)   4.1          11.3

Google spreadsheet with detailed results:
CanvasMatrix doesn't use typed arrays at all.

Some of the other ones might.

It's worth filing a separate tracking bug for that test suite.  It would also be a good addition to the suite to allow running a single test easily.
Target Milestone: --- → mozilla10
Depends on: 957690
Assignee: general → nobody

Resolving as Fixed because all dependent bugs are marked fixed.

Closed: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.