Skip to main content

MemoryStats

Struct MemoryStats 

Source
pub struct MemoryStats {
Show 15 fields pub block_cache_hits: u64, pub block_cache_misses: u64, pub block_cache_evictions: u64, pub block_cache_capacity_bytes: usize, pub key_cache_hits: u64, pub key_cache_misses: u64, pub key_cache_evictions: u64, pub key_cache_invalidations: u64, pub key_cache_resident_bytes: usize, pub key_cache_capacity_bytes: usize, pub row_cache_hits: u64, pub row_cache_misses: u64, pub total_memory_used: usize, pub buffer_allocations: u64, pub buffer_deallocations: u64,
}
Expand description

Memory statistics.

Public-surface-wired (semver) through Database::stats().memory_stats. The field names and types are preserved verbatim (issue #1568, AK6); only the source of the block-cache numbers changed — they now reflect the real B1 DecompressedChunkCache.

§Independent sampling (advisory observability)

The block_cache_* fields and the key_cache_* fields are sampled independently and at different instants: the block-cache figures come from the MemoryManager (its shared B1 chunk cache), while the key-cache figures are aggregated from the storage engine’s per-reader B4 caches (SSTableManager::aggregate_key_cache_stats) in a separate step. Under concurrent read load the two groups can therefore reflect slightly different moments in time, so within a single memory_stats snapshot the block-cache vs key-cache figures are not guaranteed to be mutually coherent. Treat this as advisory observability (trends, rough ratios), not a transactionally-consistent point-in-time view of both caches.

Fields§

§block_cache_hits: u64

Block cache hits (real B1 cache hit count when wired).

§block_cache_misses: u64

Block cache misses (real B1 cache miss count when wired).

§block_cache_evictions: u64

Block cache evictions: entries the B1 decompressed-chunk cache evicted to stay within its byte budget (issue #1571, B5). Real eviction_count() when wired; 0 (honest — no cache, no evictions) otherwise. High churn relative to hits signals an undersized block_cache_capacity_bytes.

§block_cache_capacity_bytes: usize

Block cache configured byte budget (issue #1571, B5): the B1 cache’s budget_bytes() when wired, so a hit rate can be read against the budget it was measured under; 0 when no cache is wired / block caching disabled.

§key_cache_hits: u64

Key cache hits (issue #1571/#2059). A hit lets a repeated point read skip the Index.db interval parse. Since #2059 the key cache is ONE process-global instance shared by every open reader, so these counters are PROCESS-GLOBAL: they aggregate activity across ALL Database instances in the process, not one reader’s slice (a semantic change from the retired per-reader counters). Real counter; 0 before any reader touches the cache.

§key_cache_misses: u64

Key cache misses (issue #1571/#2059). Process-global, like key_cache_hits — summed across all Database instances in the process.

§key_cache_evictions: u64

Key cache evictions: entries evicted from the process-global key cache to stay within its byte budget (issue #1571/#2059) — DISTINCT from key_cache_invalidations.

§key_cache_invalidations: u64

Key cache invalidations: entries dropped from the process-global key cache on generation removal / compaction / warm-registry evict (issue #2059) — a distinct counter from budget-driven key_cache_evictions.

§key_cache_resident_bytes: usize

Key cache resident bytes: approximate resident footprint of the process-global key cache (issue #1571/#2059).

§key_cache_capacity_bytes: usize

Key cache capacity bytes: the process-global key cache’s fixed configured byte budget (issue #1571/#2059), or 0 when block caching is disabled.

§row_cache_hits: u64

Row cache hits. Retained for shape compatibility; the row cache was deleted (issue #1568), so this reports 0 (full surface is Epic B / B5).

§row_cache_misses: u64

Row cache misses. Retained for shape compatibility; reports 0.

§total_memory_used: usize

Total memory used. Now the B1 cache’s resident decompressed bytes (resident_bytes()) when wired (issue #1568).

§buffer_allocations: u64

Buffer pool allocations. Retained for shape compatibility; the buffer pool was deleted (issue #1568), so this reports 0.

§buffer_deallocations: u64

Buffer pool deallocations. Retained for shape compatibility; reports 0.

Implementations§

Source§

impl MemoryStats

Source

pub fn block_cache_hit_rate(&self) -> f64

Calculate block cache hit rate.

Source

pub fn key_cache_hit_rate(&self) -> f64

Calculate the aggregate key-cache hit rate (issue #1571, B5) from the real summed hit and miss counts. Returns 0.0 when there has been no key-cache activity (honest — not a structural pin).

Source

pub fn row_cache_hit_rate(&self) -> f64

Calculate row cache hit rate.

Trait Implementations§

Source§

impl Clone for MemoryStats

Source§

fn clone(&self) -> MemoryStats

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 MemoryStats

Source§

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

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

impl Default for MemoryStats

Source§

fn default() -> MemoryStats

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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