Skip to main content

BudgetSnapshot

Struct BudgetSnapshot 

Source
pub struct BudgetSnapshot {
    pub target_bytes: u64,
    pub effective_target_bytes: u64,
    pub rss_bytes: u64,
    pub rss_sysinfo_bytes: u64,
    pub lease_bytes_active: u64,
    pub jemalloc: JemallocStats,
    pub verdict: Verdict,
    pub verdict_streak: u32,
    pub previous_verdict_label: Option<&'static str>,
    pub previous_verdict_streak: Option<u32>,
    pub caches: Vec<CacheSnapshot>,
    pub reporters: Vec<ReporterSnapshot>,
}
Expand description

Diagnostic snapshot of one budget tick.

Fields§

§target_bytes: u64

Configured target RSS in bytes.

§effective_target_bytes: u64

Target after active-lease subtraction.

§rss_bytes: u64

Effective RSS the policy used this tick. When jemalloc stats are present this is jemalloc.resident_bytes (the true resident footprint); otherwise it falls back to the sysinfo reading in BudgetSnapshot::rss_sysinfo_bytes.

On some platforms, the operating-system reading can diverge materially from the allocator’s resident estimate. Driving the policy off jemalloc.resident keeps grow/shrink decisions aligned with the allocator when those statistics are available.

§rss_sysinfo_bytes: u64

Raw sysinfo RSS reading (phys_footprint on macOS, RSS on Linux). Kept for the gap diagnostic — compare against BudgetSnapshot::rss_bytes to see how far the OS-reported footprint diverges from jemalloc’s view. Equals rss_bytes when no jemalloc stats are available.

§lease_bytes_active: u64

Sum of bytes reserved by live LeaseGuards.

§jemalloc: JemallocStats

jemalloc introspection at tick time. Splits the non-cache bucket into “live allocations the program holds” (JemallocStats::allocated_bytes) and “pages jemalloc has not yet returned to the kernel” (JemallocStats::retained_bytes). Zero on builds that do not install jemalloc.

§verdict: Verdict

What the policy decided this tick and why.

§verdict_streak: u32

Number of consecutive ticks (including this one) that have ended in the same Verdict label. Resets to 1 when the label changes. Useful for spotting wedges in post-mortem logs (“the budget has been at skip-shrink-lean-caches for 480 ticks”) without arithmetic on timestamps.

§previous_verdict_label: Option<&'static str>

When the verdict label changed at this tick, the label of the previous run; None otherwise. Lets post-mortem capture the length of the run that just ended via BudgetSnapshot::previous_verdict_streak.

§previous_verdict_streak: Option<u32>

Length of the run that just ended (Some when BudgetSnapshot::previous_verdict_label is Some).

§caches: Vec<CacheSnapshot>

One entry per still-live registered cache.

§reporters: Vec<ReporterSnapshot>

One entry per still-live registered NonCacheReporter (e.g. the reasoner working-set gauge). Names slices of the otherwise-opaque non_cache_live bucket.

Implementations§

Source§

impl BudgetSnapshot

Source

pub fn cap_bytes_after(&self) -> u64

Sum of new_max_bytes across every cache after the tick. Useful when logging “what did the budget reapportion to”.

Source

pub fn cache_bytes_current(&self) -> u64

Sum of current_bytes across every cache at tick time — i.e. live cache footprint, before the new cap is applied.

Source

pub fn non_cache_bytes(&self) -> u64

rss_bytes − cache_bytes_current − lease_bytes_active, saturating at zero. This is the non-cache bucket: heap that the budget knows about but cannot resize — typically transient allocator state (parser context, query result buffers, or other working memory) plus the non-reclaimable parts of jemalloc’s retained-decommitted pages.

Surfaced on every tick emission as non_cache_bytes so post-mortem analysis can attribute RSS growth to a specific bucket (cache pressure vs. non-cache spike) instead of inferring it from the cache breakdown. See BudgetSnapshot::non_cache_live_bytes for the further jemalloc-attributed split.

Source

pub fn non_cache_live_bytes(&self) -> u64

Non-cache bytes attributed to live application allocations by jemalloc: je_allocated_bytes − cache_bytes_current − lease_bytes_active, saturating at zero.

Reading this alongside non_cache_bytes is the diagnostic that separates real leaks from jemalloc retention. If non_cache_live_bytes is flat across a long-running soak but non_cache_bytes keeps growing, the growth is jemalloc retained pages (jemalloc.retained_bytes) — an allocator tuning issue. If non_cache_live_bytes itself grows, the program is holding more memory (a leak somewhere outside the registered caches).

Zero on builds that do not install jemalloc.

Source

pub fn reporter_bytes(&self) -> u64

Sum of current_bytes across all live non-cache reporters — the attributed portion of non_cache_live_bytes.

Source

pub fn non_cache_other_bytes(&self) -> u64

non_cache_live_bytes − reporter_bytes, saturating at zero — the unattributed remainder of the live non-cache bucket (parser context, query buffers, transient allocator state, and any subsystem that hasn’t registered a reporter yet).

Trait Implementations§

Source§

impl Clone for BudgetSnapshot

Source§

fn clone(&self) -> BudgetSnapshot

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 Debug for BudgetSnapshot

Source§

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

Formats the value using the given formatter. Read more

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<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> 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