This paper, originally presented at USENIX ATC '18 and expanded here, introduces HashKV, a storage engine designed to solve the "garbage collection bottleneck" in modern key-value (KV) stores.
TL;DR
HashKV uses hash-based data grouping to rethink how values are stored in KV separation designs. By deterministically mapping values to storage partitions, it eliminates the need for expensive metadata lookups during garbage collection, achieving up to 4.6× higher throughput and 53.4% less write traffic than existing state-of-the-art designs.
What Problem Does This Paper Address?
Most persistent KV stores (like LevelDB or RocksDB) use Log-Structured Merge (LSM) trees. While great for write performance, LSM-trees suffer from high I/O amplification—they constantly rewrite data during "compaction" to keep keys sorted.
A popular optimization is KV separation (pioneered by WiscKey), which keeps small keys in the LSM-tree but moves large values to a separate circular log. However, this creates a new headache: Garbage Collection (GC). To reclaim space in a circular log, the system must constantly "clean" the tail of the log, checking the LSM-tree to see if each value is still valid and relocating valid data to the head. In update-intensive workloads, this GC process becomes a massive performance sink, causing high latency and wearing out SSDs.
Methods
The authors propose HashKV, which replaces the circular log with hash-based data grouping.
- Deterministic Mapping: Instead of appending values to a single log, HashKV partitions the value store into fixed-size "main segments." A value is mapped to a segment by hashing its key.
- Lightweight GC: Because all versions of a specific key are hashed to the same segment, GC becomes "local." To reclaim space, HashKV simply scans a segment; the version closest to the end is the valid one. This eliminates the need to query the LSM-tree during GC.
- Dynamic Extensions: To handle the rigidity of hashing (e.g., what if one segment gets too many updates?), they introduced:
- Dynamic Reserved Space: If a main segment fills up, HashKV dynamically allocates "log segments" from a reserved pool.
- Hotness Awareness: They use a "tagging" approach to identify cold data and move it to a separate area, preventing it from being repeatedly copied during GC of hot segments.
- Selective Separation: Very small KV pairs are kept entirely within the LSM-tree to avoid the overhead of separate I/O.
Datasets
The authors evaluated HashKV using:
- YCSB (Yahoo! Cloud Serving Benchmark): The industry standard for KV store evaluation, including update-heavy, read-heavy, and latest-read workloads.
- Synthetic Skewed Workloads: Using Zipf distributions to simulate real-world data "hotness."
- Integration Tests: They replaced the backends of LevelDB, RocksDB, HyperLevelDB, and PebblesDB with HashKV to show its generalizability.
Key Insights and Ideas
- The "Aha" Moment on GC: In traditional KV separation, GC is slow because it's "blind"—it doesn't know which key a value belongs to without checking the LSM-tree. By using hashing, HashKV makes the value store "self-describing" for the purpose of validity checks.
- Random Writes aren't the Enemy (on SSDs): Hashing inherently causes random writes. While this would be fatal on hard drives, the authors argue (and prove) that on modern SSDs, the performance gap between random and sequential writes is small enough that the massive reduction in GC overhead far outweighs the random write penalty.
- Flexibility via Log Segments: Pure hashing is often avoided in storage because it handles data growth poorly. HashKV’s use of "segment groups" (a main segment plus linked log segments) provides the flexibility of a log-structured system with the look-up efficiency of a hash table.
Key Results
- Throughput: HashKV achieves 4.6× the update throughput of WiscKey (the leading KV separation design) under update-intensive workloads.
- Write Reduction: It generates 53.4% less write traffic than WiscKey, significantly extending SSD lifespan.
- Latency: Average update latency is reduced by up to 20× compared to circular log designs because the "GC-Lookup" phase is entirely eliminated.
- Versatility: When integrated into RocksDB, HashKV improved throughput by 1.2× to 5.0× across various YCSB workloads.
Limitations and Future Work
- Range Scans: Like all KV separation designs, range scans are slower than pure LSM-trees because values are not stored in sorted order. HashKV uses prefetching (read-ahead) to mitigate this, but it remains a trade-off.
- Memory Overhead: HashKV requires an in-memory "segment table" to track the locations of log segments. While small (a few MiB for GiBs of data), it is an additional requirement.
- Crash Consistency: While the paper describes a journaling mechanism for crash consistency, the extra writes for journaling slightly offset the performance gains, though the net benefit remains high.
Overall, HashKV makes a compelling case that for the modern SSD era, deterministic data placement is a superior strategy for managing the "value" part of KV stores.
Summary updated