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: u64Configured target RSS in bytes.
effective_target_bytes: u64Target after active-lease subtraction.
rss_bytes: u64Effective 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: u64Raw 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: u64Sum of bytes reserved by live LeaseGuards.
jemalloc: JemallocStatsjemalloc 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: VerdictWhat the policy decided this tick and why.
verdict_streak: u32Number 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
impl BudgetSnapshot
Sourcepub fn cap_bytes_after(&self) -> u64
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”.
Sourcepub fn cache_bytes_current(&self) -> u64
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.
Sourcepub fn non_cache_bytes(&self) -> u64
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.
Sourcepub fn non_cache_live_bytes(&self) -> u64
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.
Sourcepub fn reporter_bytes(&self) -> u64
pub fn reporter_bytes(&self) -> u64
Sum of current_bytes across all live non-cache reporters —
the attributed portion of non_cache_live_bytes.
Sourcepub fn non_cache_other_bytes(&self) -> u64
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
impl Clone for BudgetSnapshot
Source§fn clone(&self) -> BudgetSnapshot
fn clone(&self) -> BudgetSnapshot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more