cojen / TuplDB

TuplDB is a high-performance, concurrent, transactional, scalable, low-level embedded database.
GNU Affero General Public License v3.0
117 stars 23 forks source link

Don't dirty leaf node when splitting on an edge #109

Open broneill opened 5 years ago

broneill commented 5 years ago

When inserting a new entry, the leaf node is always dirtied in advance. If the leaf needs to split, and it splits on an edge, then dirtying the node was unnecessary, and it causes an extra page to be written.

broneill commented 5 years ago

Implementing this is tricky, due to how root node splits are handled. When finishing a split, if the node is the root node or if it becomes the root node during latch re-acquisition, then the original node must be in a dirty state. This is because it will remain as the root, and so it gets promoted to become the parent node.