mattbierner / hamt

Javascript Hash Array Mapped Trie
MIT License
251 stars 16 forks source link

Use interleaved key value arrays #10

Open mattbierner opened 8 years ago

mattbierner commented 8 years ago

First step of trying out #4, using interleaved key, value arrays like the clojure implementation does.

This is supposed to improve cache performance since no extra memory indirection is required to access leaf nodes.

The downsides are that it complicates the implementation and will require rethinking the internal structures a lot. There is also no guaranteed this will actually improve performance on a modern Javascript engine. In fact, when I tried this out as a simple experiment, it made the performance worse.

V1.0 gets the API into a better state to support this type of change.

mattbierner commented 8 years ago

Simple benchmark shows that striding has little benefit on its own: http://jsperf.com/strided-array-iteration

It could enable more optimizations though so perhaps still worth investigating.