pub struct PoolingPolicy {
pub min_size_bytes: usize,
pub max_size_bytes: usize,
pub min_frequency: usize,
pub memory_pressure_threshold: f64,
pub adaptive: bool,
}Expand description
Policy for determining when to use buffer pooling
Fields§
§min_size_bytes: usizeMinimum buffer size in bytes to pool
max_size_bytes: usizeMaximum buffer size in bytes to pool
min_frequency: usizeMinimum access frequency for a shape
memory_pressure_threshold: f64Available memory threshold (0.0-1.0) Don’t pool aggressively if available memory is low
adaptive: boolEnable adaptive thresholds based on runtime behavior
Implementations§
Source§impl PoolingPolicy
impl PoolingPolicy
Sourcepub fn conservative() -> Self
pub fn conservative() -> Self
Create a conservative policy (pool only large, frequently accessed buffers)
Sourcepub fn aggressive() -> Self
pub fn aggressive() -> Self
Create an aggressive policy (pool most buffers)
Sourcepub fn memory_constrained() -> Self
pub fn memory_constrained() -> Self
Create a memory-constrained policy (minimize memory usage)
Sourcepub fn should_pool(&self, shape: &[usize], elem_size: usize) -> bool
pub fn should_pool(&self, shape: &[usize], elem_size: usize) -> bool
Sourcepub fn should_pool_with_frequency(
&self,
shape: &[usize],
elem_size: usize,
frequency: usize,
) -> bool
pub fn should_pool_with_frequency( &self, shape: &[usize], elem_size: usize, frequency: usize, ) -> bool
Check if we should pool based on access frequency
This should be called after tracking access patterns.
Sourcepub fn with_memory_pressure(&self, available_memory_ratio: f64) -> Self
pub fn with_memory_pressure(&self, available_memory_ratio: f64) -> Self
Trait Implementations§
Source§impl Clone for PoolingPolicy
impl Clone for PoolingPolicy
Source§fn clone(&self) -> PoolingPolicy
fn clone(&self) -> PoolingPolicy
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PoolingPolicy
impl Debug for PoolingPolicy
Auto Trait Implementations§
impl Freeze for PoolingPolicy
impl RefUnwindSafe for PoolingPolicy
impl Send for PoolingPolicy
impl Sync for PoolingPolicy
impl Unpin for PoolingPolicy
impl UnwindSafe for PoolingPolicy
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)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>
Converts
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>
Converts
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