#[non_exhaustive]pub struct SegmentSizeStats {
pub count: u64,
pub min_bytes: u64,
pub max_bytes: u64,
pub mean_bytes: u64,
pub p50_bytes: u64,
pub p90_bytes: u64,
}Expand description
Size distribution of the on-disk segment files at a point in time.
Returned by SegmentBuffer::segment_size_stats. Unlike
BufferStats (which derives BufferStats::segment_count and
BufferStats::approx_disk_bytes from cheap atomic counters maintained
on the flush/delete hot path), this struct is computed by a fresh
directory scan: every field reflects the segment files as they actually
are at call time. It is the tuning primitive for FlushPolicy::Batch:
it answers “are my segments the size I expect, or is the batch size
producing too many tiny files / too few huge ones?”
All byte values are the on-disk (compressed, post-envelope) file lengths, not item counts. Two segments holding the same number of items can differ in bytes because of compression and payload shape, so byte-size distribution is the honest signal for disk-footprint tuning.
§Percentile definition
p50_bytes and p90_bytes use
the nearest-rank method: the value returned is always an actual
segment file size, never an interpolation between two. For n segments
sorted ascending, the p-th percentile is the element at 1-based rank
clamp(ceil(p / 100 · n), 1, n). Consequences:
- With one segment,
min,p50,p90, andmaxare all equal. p50is the lower median (theceil(n / 2)-th smallest element).p90is the size at or below which ~90% of segments fall.
When the buffer has no on-disk segments (nothing flushed yet, or
everything acked), every field is 0.
This struct is #[non_exhaustive]: new fields (e.g. p99_bytes) may be
added in any release without breaking semver.
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.count: u64Number of segment files on disk at scan time. Equals
BufferStats::segment_count immediately after a
sync_disk_bytes, but may differ
from the live atomic counter between recalibrations.
min_bytes: u64Smallest segment file size in bytes. 0 when there are no segments.
max_bytes: u64Largest segment file size in bytes. 0 when there are no segments.
mean_bytes: u64Arithmetic mean segment size (total_bytes / count), truncated to
the integer. 0 when there are no segments.
p50_bytes: u64Median (50th percentile) segment size, nearest-rank. 0 when there
are no segments.
p90_bytes: u6490th percentile segment size, nearest-rank. 0 when there are no
segments.
Trait Implementations§
Source§impl Clone for SegmentSizeStats
impl Clone for SegmentSizeStats
Source§fn clone(&self) -> SegmentSizeStats
fn clone(&self) -> SegmentSizeStats
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more