pub struct CompactionConfig {
pub min_bytes: u64,
pub max_segments: usize,
pub tombstone_grace: Duration,
pub emit_snapshot: bool,
}Expand description
Coordinates background segment merges to keep disk usage and read amplification under control.
The intended lifecycle for a single compaction run is:
- Inspect storage metadata and pick cold segments whose combined size
exceeds
min_bytesor whose live-data ratio falls below a future heuristic. We cap the batch usingmax_segmentsto avoid long stalls. - Stream the chosen segments in log order, retaining the newest value per
key while skipping tombstones older than
tombstone_grace. - Write the surviving entries into a fresh segment, fsync it, rebuild its sparse index/Bloom filter, and atomically swap it into Storage while removing the old segment files.
- Optionally trigger snapshotting so restart time stays stable even as log history churns. Configuration for compaction behavior
Fields§
§min_bytes: u64Minimum bytes needed before compaction runs
max_segments: usizeMaximum number of segments to compact at once
tombstone_grace: DurationHow long to keep tombstones before eviction
emit_snapshot: boolWhether to emit a snapshot after compaction
Trait Implementations§
Source§impl Clone for CompactionConfig
impl Clone for CompactionConfig
Source§fn clone(&self) -> CompactionConfig
fn clone(&self) -> CompactionConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CompactionConfig
impl Debug for CompactionConfig
Auto Trait Implementations§
impl Freeze for CompactionConfig
impl RefUnwindSafe for CompactionConfig
impl Send for CompactionConfig
impl Sync for CompactionConfig
impl Unpin for CompactionConfig
impl UnsafeUnpin for CompactionConfig
impl UnwindSafe for CompactionConfig
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
Mutably borrows from an owned value. Read more