Introduction
Modern key-value (KV) stores, such as LevelDB and RocksDB, predominantly rely on Log-Structured Merge (LSM) trees. While optimized for write performance, LSM-trees suffer from significant I/O amplification due to the constant rewriting of data during compaction. A common optimization, KV separation (e.g., WiscKey), mitigates this by storing large values in a separate circular log. However, this introduces a new bottleneck: Garbage Collection (GC). In update-intensive workloads, the system must frequently clean the log, incurring high metadata lookup costs and excessive write traffic.
The HashKV Design
To address the GC bottleneck, we introduce HashKV, a storage engine that utilizes hash-based data grouping. Unlike traditional circular logs that append data sequentially, HashKV partitions the value store into fixed-size "main segments."
Deterministic Mapping and Lightweight GC
HashKV maps values to specific segments by hashing their keys. This deterministic approach makes the value store "self-describing." During GC, the system only needs to scan a single segment to identify valid data—the version closest to the end of the segment is the most recent. This eliminates the need to query the LSM-tree for validity checks, drastically reducing overhead.
Dynamic Extensions and Hotness Awareness
To handle data skew and growth, HashKV employs several optimizations:
- Dynamic Reserved Space: If a main segment exceeds its capacity, HashKV allocates "log segments" from a reserved pool, creating a linked segment group.
- Hotness Awareness: A "tagging" mechanism identifies cold data, which is then moved to a dedicated "cold data log" to prevent redundant copying during the GC of hot segments.
- Selective Separation: Small KV pairs remain within the LSM-tree to avoid unnecessary I/O overhead for tiny values.
Performance Evaluation
HashKV was evaluated using the Yahoo! Cloud Serving Benchmark (YCSB) and various synthetic workloads. The results demonstrate significant improvements over state-of-the-art designs:
- Throughput: HashKV achieves up to 4.6× higher update throughput compared to WiscKey.
- Write Reduction: It reduces write traffic by 53.4%, significantly extending the lifespan of underlying SSDs.
- Latency: Average update latency is reduced by up to 20× by eliminating the "GC-Lookup" phase.
- Generalizability: When integrated into RocksDB, HashKV improved performance by 1.2× to 5.0× across diverse workloads.
Conclusion
HashKV demonstrates that deterministic data placement via hashing is a highly effective strategy for managing value storage in modern KV engines. By rethinking the relationship between keys and their physical storage locations, HashKV overcomes the long-standing garbage collection bottleneck in KV separation designs, offering a scalable and efficient solution for update-heavy applications on modern SSDs.
Summary updated