vmware / splinterdb

High Performance Embedded Key-Value Store
https://splinterdb.org
Apache License 2.0
680 stars 57 forks source link

Design & implement support for page-deallocations and re-allocation to support CoW operations on trunk nodes. #515

Open gapisback opened 1 year ago

gapisback commented 1 year ago

This issue is item No. 2 from the larger Recovery roadmap issue #236 : Garbage Collection for CoW: Garbage Collection for CoW (a) Modify trunk to use a single mini_allocator batch [... see issue for details ]

Further details from the in-flight Recovery Design doc:

Space reclamation after CoW: Write a new allocator for the trunk that sits in between the RC-allocator and the trunk.

Currently we are using the mini allocator but that does not allow us to do garbage collection (I.e., space reclamation of older pages that CoW created newer versions of) of trunk pages.

Mini-allocator is designed to more-or-less allocate pages contiguously from an extent but is not designed to handle deallocations of individual pages. You only deallocate the entire extent sometime. This is well-suited for managing space for branches where the entire space used by a branch (and all its nodes) is deallocated when the branch is deleted. Up until CoW schemes, trunk has only ever grown and never shrunk so the existing mini-allocation design was sufficient.

For supporting CoW operations on trunk pages, we need a way to allow pages to be deallocated and, if necessary, reallocated to other pages of the trunk. When all pages in the extent are deallocated (after one or more CoW operations) the whole extent needs to be deallocated.