Optimize node allocation using `ManagedBuffer`
lorentey opened this issue · comments
It may be worthwhile to change BTreeNode
to derive from ManagedBuffer
, replacing its Array
stored properties with a large buffer that's allocated at once.
Splitting the raw buffer into multiple areas for the various components (keys, values, children) while observing their alignment requirements will be an interesting challenge. Also, new internal API needs to be designed to provide access to data stored in the buffer.
It is probably OK to allocate space for order
elements even if not all slots are going to be filled; so we probably will not need to realloc nodes. However, leaf nodes should not allocate any space for child references that will never be set.
It is possible that the increased code complexity resulting from this change outweighs its performance advantages. (And it may even turn out that messing with data access will decrease performance.) So any implementation must demonstrate a clear win in benchmarks before it can be considered for merging.