pub struct Leveled { /* private fields */ }Expand description
Leveled compaction strategy (LCS)
When a level reaches some threshold size, parts of it are merged into overlapping tables in the next level.
Each level Ln for n >= 2 can have up to level_base_size * ratio^(n - 1) tables.
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/
Implementations§
Source§impl Strategy
impl Strategy
Sourcepub fn with_level_ratio_policy(self, policy: Vec<f32>) -> Self
pub fn with_level_ratio_policy(self, policy: Vec<f32>) -> Self
Sets the growth ratio between levels.
Same as set_max_bytes_for_level_multiplier in RocksDB.
Default = [10.0]
Sourcepub fn with_l0_threshold(self, threshold: u8) -> Self
pub fn with_l0_threshold(self, threshold: u8) -> Self
Sets the L0 threshold.
When the number of tables in L0 reaches this threshold, they are merged into L1.
Same as level0_file_num_compaction_trigger in RocksDB.
Default = 4
Sourcepub fn with_table_target_size(self, bytes: u64) -> Self
pub fn with_table_target_size(self, bytes: u64) -> Self
Sets the table target size on disk (possibly compressed).
Same as target_file_size_base in RocksDB.
Default = 64 MiB
Sourcepub fn with_dynamic_level_bytes(self, enabled: bool) -> Self
pub fn with_dynamic_level_bytes(self, enabled: bool) -> Self
Enables dynamic level sizing based on actual data in the last level.
When enabled, level target sizes are computed top-down from the actual size of the last non-empty level, divided by the ratio at each step. This reduces space amplification to ~1.1x while keeping write amplification comparable to static leveling.
Same as level_compaction_dynamic_level_bytes in RocksDB.
Default = false
Sourcepub fn with_multi_level(self, enabled: bool) -> Self
pub fn with_multi_level(self, enabled: bool) -> Self
Enables multi-level compaction optimization.
When L0→L1 compaction is selected but L1 already exceeds its target size, this option allows compacting L0+L1 directly into L2 in one pass, avoiding the write-then-rewrite cycle that would otherwise occur.
Default = false
Trait Implementations§
Source§impl CompactionStrategy for Strategy
impl CompactionStrategy for Strategy
Source§fn pending_compaction_bytes(&self, version: &Version) -> u64
fn pending_compaction_bytes(&self, version: &Version) -> u64
RocksDB estimate-pending-compaction-bytes analog). A scheduler /
tiering consumer reads it as a compaction-debt signal; 0 means the tree
is at or below its target shape. Read moreAuto Trait Implementations§
impl Freeze for Strategy
impl RefUnwindSafe for Strategy
impl Send for Strategy
impl Sync for Strategy
impl Unpin for Strategy
impl UnsafeUnpin for Strategy
impl UnwindSafe for Strategy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more