pub struct BufferPoolConfig {
pub min_size: NonZeroUsize,
pub max_size: NonZeroUsize,
pub max_per_class: NonZeroUsize,
pub prefill: bool,
pub alignment: NonZeroUsize,
}Expand description
Configuration for a buffer pool.
Fields§
§min_size: NonZeroUsizeMinimum buffer size. Must be >= alignment and a power of two.
max_size: NonZeroUsizeMaximum buffer size. Must be a power of two and >= min_size.
max_per_class: NonZeroUsizeMaximum number of buffers per size class.
prefill: boolWhether to pre-allocate all buffers on pool creation.
alignment: NonZeroUsizeBuffer alignment. Must be a power of two.
Use page_size() for storage I/O and cache_line_size() for network I/O.
Implementations§
Source§impl BufferPoolConfig
impl BufferPoolConfig
Sourcepub const fn for_network() -> Self
pub const fn for_network() -> Self
Network I/O preset: cache-line aligned, cache_line_size to 64KB buffers, 4096 per class, not prefilled.
Network operations typically need multiple concurrent buffers per connection (message, encoding, encryption) so we allow 4096 buffers per size class. Cache-line alignment is used because network buffers don’t require page alignment for DMA, and smaller alignment reduces internal fragmentation.
Sourcepub fn for_storage() -> Self
pub fn for_storage() -> Self
Storage I/O preset: page-aligned, page_size to 8MB buffers, 32 per class, not prefilled.
Page alignment is required for direct I/O and efficient DMA transfers.
Sourcepub const fn with_min_size(self, min_size: NonZeroUsize) -> Self
pub const fn with_min_size(self, min_size: NonZeroUsize) -> Self
Returns a copy of this config with a new minimum buffer size.
Sourcepub const fn with_max_size(self, max_size: NonZeroUsize) -> Self
pub const fn with_max_size(self, max_size: NonZeroUsize) -> Self
Returns a copy of this config with a new maximum buffer size.
Sourcepub const fn with_max_per_class(self, max_per_class: NonZeroUsize) -> Self
pub const fn with_max_per_class(self, max_per_class: NonZeroUsize) -> Self
Returns a copy of this config with a new maximum number of buffers per size class.
Sourcepub const fn with_prefill(self, prefill: bool) -> Self
pub const fn with_prefill(self, prefill: bool) -> Self
Returns a copy of this config with a new prefill setting.
Sourcepub const fn with_alignment(self, alignment: NonZeroUsize) -> Self
pub const fn with_alignment(self, alignment: NonZeroUsize) -> Self
Returns a copy of this config with a new alignment.
Sourcepub fn with_budget_bytes(self, budget_bytes: NonZeroUsize) -> Self
pub fn with_budget_bytes(self, budget_bytes: NonZeroUsize) -> Self
Returns a copy of this config sized for an approximate tracked-memory budget.
This computes max_per_class as:
ceil(budget_bytes / sum(size_class_bytes))
where size_class_bytes includes every class from min_size to max_size.
This always rounds up to at least one buffer per size class, so the
resulting estimated capacity may exceed budget_bytes.
Trait Implementations§
Source§impl Clone for BufferPoolConfig
impl Clone for BufferPoolConfig
Source§fn clone(&self) -> BufferPoolConfig
fn clone(&self) -> BufferPoolConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for BufferPoolConfig
impl RefUnwindSafe for BufferPoolConfig
impl Send for BufferPoolConfig
impl Sync for BufferPoolConfig
impl Unpin for BufferPoolConfig
impl UnsafeUnpin for BufferPoolConfig
impl UnwindSafe for BufferPoolConfig
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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