LSM Hybrid Compaction with Partial Key-Range Merging

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

LSM trees face inefficiencies in compaction processes, particularly in large databases, leading to prolonged rewrite times and significant storage space consumption due to the need to maintain twice the size of the last layer for compaction, and high write amplification.

Innovation Solution

Implementing partial compaction in LSM trees, where compaction is broken down into smaller, targeted processes that merge specific ranges of data across levels, reducing write amplification and storage requirements by maintaining consistent key ranges across levels.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If full compaction is performed on the last layer of LSM tree, then data is consolidated and query performance is improved, but storage space consumption doubles and compaction time increases significantly

Engineering Contradiction:
Improvequery performanceVSAvoidstorage space consumption
Core Design Contradiction:
ReliabilityVSQuantity of substance

Solution Approach 1:

The patent segments the compaction process into partial compactions of different levels rather than performing a single full compaction. The last layer is divided into multiple level-zero sorted runs, and compaction is performed incrementally on portions of data at different levels (L0, L1, L2, etc.), allowing the system to consolidate data improvement query performance while avoiding the need to hold all data in memory simultaneously, thus reducing peak storage space requirements

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent implements dynamic compaction where the system adaptively decides which levels and portions of data to compact based on current system state, query patterns, and available resources. The compaction process is made dynamic by allowing it to operate on different levels (L0-L6) and different sorted runs selectively, rather than following a fixed full-compaction schedule, enabling the system to balance performance improvement with storage space management

Inventive Principle:
Principle #15Dynamics

2Reliability

If full compaction is performed on the last layer of LSM tree, then data is consolidated and query performance is improved, but compaction time increases significantly

Engineering Contradiction:
Improvequery performanceVSAvoidcompaction time
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The patent segments the compaction process into multiple smaller partial compactions operating on different levels and sorted runs simultaneously. Instead of one long full-compaction operation that halts or slows down queries, the system performs multiple shorter compactions in parallel or sequence across different data portions, reducing the time impact on query performance while still achieving data consolidation benefits

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent enables continuous query processing during compaction operations by allowing queries to access data at any level while compaction is in progress. The system maintains the invariant that data can be read from any level, so queries continue to execute without interruption while background compaction consolidates data, eliminating the need to stop or slow down the system for compaction

Inventive Principle:
Principle #20Continuity of useful action

3Productivity

If LSM tree maintains data in multiple levels with last layer being largest, then insert performance is optimized, but write amplification increases during compaction

Engineering Contradiction:
Improveinsert performanceVSAvoidwrite amplification
Core Design Contradiction:
ProductivityVSLoss of energy

Solution Approach 1:

The patent applies partial compaction rather than full compaction at each level. Instead of compacting all data at the last layer, the system performs partial compactions on selected sorted runs and levels based on size thresholds and system state. This partial action reduces the total volume of data being rewritten, thereby reducing write amplification while still maintaining insert performance benefits of the multi-level structure

Inventive Principle:
Principle #16Partial or excessive action

Solution Approach 2:

The patent dynamically changes compaction parameters such as the threshold for triggering compaction, the maximum size of sorted runs to compact, and the selection of which levels to compact based on current system conditions. By adjusting these parameters, the system optimizes the balance between maintaining insert performance (which requires the multi-level structure) and reducing write amplification (which requires minimizing compaction volume)

Inventive Principle:
Principle #35Parameter changes

Data Source

PatentUS12411828B2LSM hybrid compaction
Publication Date: 2025.09.09 REDIS LTD
  • US12411828B2 patent drawing
  • US12411828B2 patent drawing
  • US12411828B2 patent drawing

AI summary

A method for log-structured merge (LSM) tree compaction, the method includes (i) performing partial compaction processes. Each partial compaction process is associated with a target layer. Different partial compaction processes that are associated with a same target layer are allocated to different non-overlapping key ranges of the target layer. Some of the partial compaction processes are associated with a target layer that is a last layer of the LSM tree.