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.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for BufferPool
impl RefUnwindSafe for BufferPool
impl Send for BufferPool
impl Sync for BufferPool
impl Unpin for BufferPool
impl UnsafeUnpin for BufferPool
impl UnwindSafe for BufferPool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more