#[non_exhaustive]pub struct Stats {
pub level_files: Vec<usize>,
pub level_bytes: Vec<u64>,
pub memtable_bytes: u64,
pub user_bytes_written: u64,
pub disk_bytes_written: u64,
pub wal_bytes_written: u64,
pub background_idle: bool,
}Expand description
Per-level file counts + byte totals, plus write-amplification inputs.
#[non_exhaustive]: new fields may be added in a minor (0.x) release; construct via
Db::stats rather than a struct literal.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.level_files: Vec<usize>Number of live SST files per level, index 0 = L0.
level_bytes: Vec<u64>Total SST bytes per level, index 0 = L0 (parallel to Stats::level_files).
memtable_bytes: u64Approximate bytes held by the active memtable plus any frozen ones waiting to flush.
user_bytes_written: u64Total user key+value bytes ever written (the numerator/denominator base for
Stats::write_amplification; not reduced by deletes or compaction).
disk_bytes_written: u64Bytes written to SST files by flushes and compactions combined (not the WAL – see
Stats::wal_bytes_written).
wal_bytes_written: u64Bytes written to the WAL (post-fsync, i.e. only what actually reached disk).
background_idle: booltrue if the background thread has no frozen memtable to flush, isn’t mid-flush or
mid-compaction right now, and compaction::pick finds nothing to do at the current
version – i.e. the engine is quiescent as far as background work goes. A benchmark
polling for “steady state” should use this instead of watching level_bytes stop moving:
that heuristic can’t tell “actually done” apart from “between two compactions that happen
to land on the same byte totals”.
Implementations§
Source§impl Stats
impl Stats
Sourcepub fn write_amplification(&self) -> f64
pub fn write_amplification(&self) -> f64
Write amplification, defined the way RocksDB defines it: (WAL bytes + flush bytes + compaction bytes) / user bytes. disk_bytes_written already sums flush + compaction
bytes (see Db::stats), so this is (wal_bytes_written + disk_bytes_written) / user_bytes_written, or 0.0 before anything has been written.