3 ms·
You can also simply have a pointer to the value, so a node is just three pointers (prev, val, next) in a fixed sized structure. This gets you 2 nodes / CL. Add
by eternalban 4y ago
You can also simply have a pointer to the value, so a node is just three pointers (prev, val, next) in a fixed sized structure. This gets you 2 nodes / CL. Add a fixed sized hash of value (key) if you want to search the list without chasing the val pointer, and your node still fits in a 64b CL. Pad it with 24b (yes, sacrifice a bit of space for performance gain) and your nodes will cache align.
Resize point is fair but we still options here. A segmented approach for very large collections may also help, with tuning knobs of array size / segment. The smallish top level ds maintaining segment ptrs will be super hot and very likely ever present in L2.
It really all depends on how many items are involved and how the data needs to be accessed and used.