Spooky: Granulating LSM-Tree Compactions Correctly
Channel: Niv Dayan
Date: 2022-09-21

Talk at VLDB 2022 about Spooky: Granulating LSM-Tree Compactions Correctly

https://nivdayan.github.io/spooky.pdf

Modern storage engines and key-value stores have come to rely on the log-structured merge-tree (LSM-tree) as their core data structure. LSM-tree operates by gradually merge-sorting  data  across levels of exponentially increasing capacities in storage. A crucial design dimension of  LSM-tree is its compaction granularity. Some designs perform Full Merge, whereby entire levels  get compacted at once. Others perform Partial Merge, whereby smaller groups of files with overlapping key ranges are compacted independently. This paper shows that both strategies exhibit serious flaws. With Full Merge,  space-amplification is exorbitant. The reason is that while compacting the LSM-tree's largest level, there must be at least twice as much storage space as data to store both the original and new files until the compaction is finished. On the other hand, Partial Merge exhibits excessive write-amplification. The reason is twofold. The files getting compacted typically do not have perfectly overlapping key ranges, and so some non-overlapping data is superfluously rewritten in each compaction. Files with different lifetimes become interspersed within the SSD leading to high  SSD garbage-collection overheads. As the data size grows, these problems grow in magnitude.  

We introduce Spooky, a novel compaction granulation method to address these problems. Spooky partitions data at the largest level into equally sized files, and it partitions data at smaller levels based on the file boundaries at the largest level. This allows merging one group of perfectly overlapping files at a time to limit space-amplification and compaction overheads.  At the same time, Spooky writes larger though fewer files simultaneously so that files with different lifetimes do not become as interspersed within the SSD. This cheapens garbage-collection. We show empirically that Spooky achieves 2x lower space-amplification than Full Merge and 2x lower write-amplification than Partial Merge at the same time.