(no title)
postfuturist | 12 years ago
It is an implementation of a data structure invented by Phil Bagwell: http://lampwww.epfl.ch/papers/idealhashtrees.pdf
postfuturist | 12 years ago
It is an implementation of a data structure invented by Phil Bagwell: http://lampwww.epfl.ch/papers/idealhashtrees.pdf
JeanPierre|12 years ago
If you have a reference to a paper explaining something similar (or the actual implementation), I'd love to put it in the post for others.
jasonwatkinspdx|12 years ago
Looking at the source the persistent vectors are virtually identical to Bagwell's paper. Rich did add a couple tweaks, namely moving the bitvector that indicates what slots of a node are occupied from being a word in the node object to being embedded in the 64bit integers stored in each node slot. When a node is filled enough to span 2 cache lines, around 9 slots on typical hardware with 64 byte lines, and the next desired index fragment is the 9th slot or higher, this avoids touching the first cache line, potentially saving a cache miss. This is why the nodes are 32 way: 32bits for the bitvector and 32bits for the offset in the underlying storage array fit in one 64bit word which can be written atomically (inside a transient obviously). Rich goes through this in one of his talks but I don't recall which.
The modification to go from mutable to immutable isn't an invention either. Anyone who's read any of the functional data structure literature will be familiar with path copying being one of the two general ways of making any data structure persistent.
From the perspective of these data structures there's little difference between a vector with integer indexes and a hashmap. The hashmap just requires a preliminary step of hashing the key to an integer.
swannodette|12 years ago
swannodette|12 years ago