Skip to main content

DecompressedChunkCache

Struct DecompressedChunkCache 

Source
pub struct DecompressedChunkCache { /* private fields */ }
Expand description

A shared, bytes-bounded, sharded decompressed-chunk cache.

Implementations§

Source§

impl DecompressedChunkCache

Source

pub fn with_budget_bytes(total_budget_bytes: usize) -> Self

Create a cache with total_budget_bytes split across DEFAULT_SHARDS shards.

Source

pub fn with_budget_and_shards( total_budget_bytes: usize, shard_count: usize, ) -> Self

Create a cache with total_budget_bytes split across shard_count shards.

shard_count is rounded UP to the next power of two (min 1) so shard selection can mask instead of modulo. Unit tests use shard_count = 1 for deterministic eviction ordering; production uses DEFAULT_SHARDS.

Source

pub fn disabled() -> Self

Create a genuine no-op cache (issue #1568): reads bypass it entirely.

Used when config.memory.block_cache.enabled == false so the advertised toggle really disables caching instead of being decorative. get always returns None (no counters touched), insert returns the Arc without retaining it, and resident_bytes() / len() / budget_bytes() all report 0. A single dummy shard is allocated only so shard indexing stays valid; nothing is ever stored in it.

Source

pub fn get(&self, key: &ChunkKey) -> Option<Bytes>

Look up a resident chunk. On a hit this bumps recency and returns a Bytes::clone (refcount bump, no chunk-sized allocation). On a miss returns None.

Source

pub fn insert(&self, key: ChunkKey, data: Vec<u8>) -> Bytes

Insert data under key, returning the resident Bytes.

The Vec<u8> is converted to Bytes exactly once here via Bytes::from, which is ZERO-COPY: it takes ownership of the Vec’s existing heap allocation rather than allocating a new backing store and copying (issue #1940 substrate). The returned handle and any subsequent get share that one buffer (refcount-bumped clones). After insertion the owning shard evicts LRU entries until it is within its byte budget (never evicting the just-inserted entry).

Source

pub fn resident_bytes(&self) -> usize

Total resident decompressed bytes across all shards.

Source

pub fn len(&self) -> usize

Total resident entry count across all shards.

Source

pub fn is_empty(&self) -> bool

Whether the cache currently holds no entries.

Source

pub fn budget_bytes(&self) -> usize

The configured total byte budget (budget_per_shard * shard count).

A disabled no-op cache reports 0 (it holds nothing).

Source

pub fn hit_count(&self) -> u64

Cumulative cache hits (test/observability instrumentation).

Source

pub fn miss_count(&self) -> u64

Cumulative cache misses (test/observability instrumentation).

Source

pub fn eviction_count(&self) -> u64

Cumulative entries evicted to stay within budget (issue #1571, B5).

Real relaxed-atomic counter; a disabled no-op cache never evicts and reports 0.

Trait Implementations§

Source§

impl Debug for DecompressedChunkCache

Source§

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

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

impl Default for DecompressedChunkCache

Source§

fn default() -> Self

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