by butterisgood · 5y ago · 0 comments
I suppose some cache-friendliness may also come from the chosen memory allocator for allocating new nodes. If objects are all the same size, a reasonably good slab allocator might continue to provide cache-friendliness.
I think I need an adult! Can someone help me sort this out?
[1] https://attractivechaos.wordpress.com/2008/09/24/b-tree-vs-b...
In C terms as in this case that means that the pointers required of individual nodes aren't allocated in separate structs and are instead embedded in one struct that also includes the payload.
This means that the cache behavior is improved, as a given node is stored in a single location. Once you access a node the associated data is already in the cache, instead of having to be fetched via a separate pointer dereference.