TriangleKV: Reducing Write Stalls and Write Amplification in LSM-Tree Based KV Stores With Triangle Container in NVM

Popular LSM-tree based key-value stores suffer from suboptimal and unpredictable performance due to write amplification and write stalls that cause application performance to periodically drop to nearly zero. Our preliminary experimental studies reveal that (1) write stalls mainly stem from the significantly large amount of data involved in each compaction between <inline-formula><tex-math notation="LaTeX">$L_{0}$</tex-math><alternatives><mml:math><mml:msub><mml:mi>L</mml:mi><mml:mn>0</mml:mn></mml:msub></mml:math><inline-graphic xlink:href="wan-ieq1-3188268.gif"/></alternatives></inline-formula>-<inline-formula><tex-math notation="LaTeX">$L_{1}$</tex-math><alternatives><mml:math><mml:msub><mml:mi>L</mml:mi><mml:mn>1</mml:mn></mml:msub></mml:math><inline-graphic xlink:href="wan-ieq2-3188268.gif"/></alternatives></inline-formula> (i.e., the first two levels of LSM-tree), and (2) write amplification increases with the depth of LSM-trees. Existing work mainly focus on reducing write amplification, while only a couple of them target mitigating write stalls. In this paper, we exploit unique features of non-volatile memory (NVM) to address these two limitations and propose TriangleKV, a new LSM-tree based persistent KV store with multi-tier DRAM-NVM-SSD storage. TriangleKV's design principles include performing smaller and cheaper <inline-formula><tex-math notation="LaTeX">$L_{0}$</tex-math><alternatives><mml:math><mml:msub><mml:mi>L</mml:mi><mml:mn>0</mml:mn></mml:msub></mml:math><inline-graphic xlink:href="wan-ieq3-3188268.gif"/></alternatives></inline-formula>-<inline-formula><tex-math notation="LaTeX">$L_{1}$</tex-math><alternatives><mml:math><mml:msub><mml:mi>L</mml:mi><mml:mn>1</mml:mn></mml:msub></mml:math><inline-graphic xlink:href="wan-ieq4-3188268.gif"/></alternatives></inline-formula> compaction to reduce write stalls while reducing the depth of LSM-trees to mitigate write amplification. To this end, four novel techniques are proposed. First, we relocate and manage the <inline-formula><tex-math notation="LaTeX">$L_{0}$</tex-math><alternatives><mml:math><mml:msub><mml:mi>L</mml:mi><mml:mn>0</mml:mn></mml:msub></mml:math><inline-graphic xlink:href="wan-ieq5-3188268.gif"/></alternatives></inline-formula> level in NVM with our proposed <italic>triangle container</italic>. Second, the new <italic>right-angle side compaction</italic> is devised to compact <inline-formula><tex-math notation="LaTeX">$L_{0}$</tex-math><alternatives><mml:math><mml:msub><mml:mi>L</mml:mi><mml:mn>0</mml:mn></mml:msub></mml:math><inline-graphic xlink:href="wan-ieq6-3188268.gif"/></alternatives></inline-formula> to <inline-formula><tex-math notation="LaTeX">$L_{1}$</tex-math><alternatives><mml:math><mml:msub><mml:mi>L</mml:mi><mml:mn>1</mml:mn></mml:msub></mml:math><inline-graphic xlink:href="wan-ieq7-3188268.gif"/></alternatives></inline-formula> at fine-grained key ranges, thus substantially reducing the amount of compaction data. Third, TriangleKV increases the width of each level to decrease the depth of LSM-trees thus mitigating write amplification. Finally, the <italic>cross-row hint search</italic> is introduced for the triangle container to keep adequate read performance. We implement TriangleKV based on MatrixKV and evaluate it on a hybrid DRAM/NVM/SSD system using Intel's latest 3D Xpoint NVM device Optane DC PMM. Evaluation results show that, with the same amount of NVM, TriangleKV outperforms RocksDB, NoveLSM and MatrixKV in 99th-percentile latencies by <inline-formula><tex-math notation="LaTeX">$5.5\times$</tex-math><alternatives><mml:math><mml:mrow><mml:mn>5</mml:mn><mml:mo>. </mml:mo><mml:mn>5</mml:mn><mml:mo>×</mml:mo></mml:mrow></mml:math><inline-graphic xlink:href="wan-ieq8-3188268.gif"/></alternatives></inline-formula>, <inline-formula><tex-math notation="LaTeX">$2.1\times$</tex-math><alternatives><mml:math><mml:mrow><mml:mn>2</mml:mn><mml:mo>. </mml:mo><mml:mn>1</mml:mn><mml:mo>×</mml:mo></mml:mrow></mml:math><inline-graphic xlink:href="wan-ieq9-3188268.gif"/></alternatives></inline-formula> and <inline-formula><tex-math notation="LaTeX">$1.1\times$</tex-math><alternatives><mml:math><mml:mrow><mml:mn>1</mml:mn><mml:mo>. </mml:mo><mml:mn>1</mml:mn><mml:mo>×</mml:mo></mml:mrow></mml:math><inline-graphic xlink:href="wan-ieq10-3188268.gif"/></alternatives></inline-formula>, and random write throughput by <inline-formula><tex-math notation="LaTeX">$4.9\times$</tex-math><alternatives><mml:math><mml:mrow><mml:mn>4</mml:mn><mml:mo>. </mml:mo><mml:mn>9</mml:mn><mml:mo>×</mml:mo></mml:mrow></mml:math><inline-graphic xlink:href="wan-ieq11-3188268.gif"/></alternatives></inline-formula>, <inline-formula><tex-math notation="LaTeX">$3.5\times$</tex-math><alternatives><mml:math><mml:mrow><mml:mn>3</mml:mn><mml:mo>. </mml:mo><mml:mn>5</mml:mn><mml:mo>×</mml:mo></mml:mrow></mml:math><inline-graphic xlink:href="wan-ieq12-3188268.gif"/></alternatives></inline-formula> and <inline-formula><tex-math notation="LaTeX">$1.4\times$</tex-math><alternatives><mml:math><mml:mrow><mml:mn>1</mml:mn><mml:mo>. </mml:mo><mml:mn>4</mml:mn><mml:mo>×</mml:mo></mml:mrow></mml:math><inline-graphic xlink:href="wan-ieq13-3188268.gif"/></alternatives></inline-formula> respectively.