pub struct Leveled {
pub l0_threshold: u8,
pub target_size: u32,
pub level_ratio: u8,
}
Expand description
Levelled compaction strategy (LCS)
When a level reaches some threshold size, parts of it are merged into overlapping segments in the next level.
Each level Ln for n >= 2 can have up to level_base_size * ratio^n
segments.
LCS suffers from comparatively high write amplification, but has decent read amplification and great space amplification (~1.1x).
LCS is the recommended compaction strategy to use.
More info here: https://fjall-rs.github.io/post/lsm-leveling/
Fields§
§l0_threshold: u8
When the number of segments in L0 reaches this threshold, they are merged into L1.
Default = 4
Same as level0_file_num_compaction_trigger
in RocksDB
.
target_size: u32
The target segment size as disk (possibly compressed).
Default = 64 MiB
Same as target_file_size_base
in RocksDB
.
level_ratio: u8
Size ratio between levels of the LSM tree (a.k.a fanout, growth rate)
This is the exponential growth of the from one. level to the next
A level target size is: max_memtable_size * level_ratio.pow(#level + 1).