pub struct Options {
pub memtable_size: usize,
pub l0_compaction_trigger: usize,
pub l1_max_bytes: u64,
pub level_multiplier: u32,
pub target_file_size: u64,
pub max_levels: usize,
pub commit_window: Duration,
}Expand description
Engine tuning knobs. See each field for the default (matches the phase-2 plan).
New fields may be added in a minor (0.x) release. Construct with
Options { memtable_size: ..., ..Default::default() } (or start from
Options::default() and mutate individual fields) rather than a full struct literal, so
adding a field there isn’t a breaking change for callers.
Fields§
§memtable_size: usizeFreeze the active memtable and roll to a new WAL once its approximate size reaches this.
This also bounds recovery time: replay on reopen never reads more than roughly
memtable_size * (1 + MAX_IMMUTABLE_MEMTABLES) bytes of WAL (the active memtable plus
however many frozen-but-unflushed ones rotate allows to queue – see
MAX_IMMUTABLE_MEMTABLES in db.rs), since anything older has already been flushed to
an SST and its WAL deleted. Each memtable can overshoot that budget by at most one
request’s bytes (write_batch’s ops are never split across a group-commit boundary), since
the writer thread stops draining a group commit once it’s already queued that many bytes
– see writer_thread’s budget in db.rs.
Range: >= MIN_MEMTABLE_SIZE (1 KiB). Db::open/open_with rejects anything smaller
with Error::InvalidArgument.
l0_compaction_trigger: usizeCompact all of L0 (+ overlapping L1) once L0 holds at least this many files.
Range: >= 1.
l1_max_bytes: u64L1’s byte budget; L_n’s budget is l1_max_bytes * level_multiplier^(n-1).
Range: >= 1.
level_multiplier: u32Per-level growth factor for the byte budget above.
Range: >= 1 (1 disables growth: every level above L1 shares L1’s budget).
target_file_size: u64Roll to a new output SST once a compaction/flush output reaches this size (only at a user-key boundary).
Range: >= 1.
max_levels: usizeNumber of levels, L0..L(max_levels-1). The bottom level is never a compaction source.
Range: 2..=255 (at least L0 + one bottom level; compaction encodes a level number as
u8, so max_levels - 1 must fit in a u8).
commit_window: DurationHow long the writer thread waits for more writes to batch after draining what’s already
queued, once at least one request has arrived. Duration::ZERO disables the wait.