Skip to main content

SegmentSizeStats

Struct SegmentSizeStats 

Source
#[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, and max are all equal.
  • p50 is the lower median (the ceil(n / 2)-th smallest element).
  • p90 is 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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§count: u64

Number 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: u64

Smallest segment file size in bytes. 0 when there are no segments.

§max_bytes: u64

Largest segment file size in bytes. 0 when there are no segments.

§mean_bytes: u64

Arithmetic mean segment size (total_bytes / count), truncated to the integer. 0 when there are no segments.

§p50_bytes: u64

Median (50th percentile) segment size, nearest-rank. 0 when there are no segments.

§p90_bytes: u64

90th percentile segment size, nearest-rank. 0 when there are no segments.

Trait Implementations§

Source§

impl Clone for SegmentSizeStats

Source§

fn clone(&self) -> SegmentSizeStats

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for SegmentSizeStats

Source§

impl Debug for SegmentSizeStats

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for SegmentSizeStats

Source§

impl PartialEq for SegmentSizeStats

Source§

fn eq(&self, other: &SegmentSizeStats) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SegmentSizeStats

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more