pub struct BufferPool { /* private fields */ }Expand description
Slab-allocating pool. Shared across tenants; tenant accounting
happens at the metrics layer only. Thread-safe via Mutex on the
per-class free lists; metrics are lock-free atomics.
Implementations§
Source§impl BufferPool
impl BufferPool
Sourcepub fn new(default_tenant_soft_limit_bytes: u64) -> Self
pub fn new(default_tenant_soft_limit_bytes: u64) -> Self
Construct with the given per-tenant default soft limit (bytes).
Sourcepub fn set_tenant_soft_limit(
&self,
tenant_id: impl Into<Arc<str>>,
soft_limit_bytes: u64,
)
pub fn set_tenant_soft_limit( &self, tenant_id: impl Into<Arc<str>>, soft_limit_bytes: u64, )
Configure a per-tenant override. Unknown tenants get the default limit on their first allocation.
Sourcepub fn acquire(&self, requested: usize) -> (Vec<u8>, PoolClass)
pub fn acquire(&self, requested: usize) -> (Vec<u8>, PoolClass)
Acquire a slab of at least requested bytes. Returns the
allocated Vec<u8> and the class it came from. The Vec is
empty (len=0) but has the capacity of its class; callers
extend_from_slice into it.
Sourcepub fn release(&self, slab: Vec<u8>, class: PoolClass)
pub fn release(&self, slab: Vec<u8>, class: PoolClass)
Return a previously acquired slab to the pool. Callers typically do this via the Drop impl of the wrapping buffer once all views have dropped. In 11.b we expose the API explicitly; a Drop-wired version lands in a follow-up revision.
Sourcepub fn record_tenant_allocation(
&self,
tenant_id: impl Into<Arc<str>>,
bytes: u64,
)
pub fn record_tenant_allocation( &self, tenant_id: impl Into<Arc<str>>, bytes: u64, )
Record bytes of live buffer allocation against a tenant.
Emits the soft-limit-exceeded counter when appropriate.
Sourcepub fn record_tenant_release(&self, tenant_id: impl Into<Arc<str>>, bytes: u64)
pub fn record_tenant_release(&self, tenant_id: impl Into<Arc<str>>, bytes: u64)
Symmetric to [record_tenant_allocation]; called when a
buffer drops.
Sourcepub fn snapshot(&self) -> BufferPoolSnapshot
pub fn snapshot(&self) -> BufferPoolSnapshot
Snapshot for metric export / tests.