pub struct SamplingConfig {
pub large_allocation_rate: f64,
pub medium_allocation_rate: f64,
pub small_allocation_rate: f64,
pub large_threshold: usize,
pub medium_threshold: usize,
pub frequency_threshold: u64,
}
Expand description
Sampling configuration for intelligent allocation tracking
Uses dual-dimension sampling (size + frequency) to balance performance with data completeness. Large allocations and high-frequency patterns receive priority sampling.
Fields§
§large_allocation_rate: f64
Sample rate for large allocations - usually 100% to catch memory leaks
medium_allocation_rate: f64
Sample rate for medium allocations - balanced approach
small_allocation_rate: f64
Sample rate for small allocations - low to reduce overhead
large_threshold: usize
Size threshold for large allocations (bytes)
medium_threshold: usize
Size threshold for medium allocations (bytes)
frequency_threshold: u64
Frequency threshold for sampling boost
Implementations§
Source§impl SamplingConfig
impl SamplingConfig
Sourcepub fn high_precision() -> Self
pub fn high_precision() -> Self
Creates high-precision configuration for debugging scenarios
Higher sampling rates for more complete data capture at the cost of increased performance overhead.
Sourcepub fn performance_optimized() -> Self
pub fn performance_optimized() -> Self
Creates performance-optimized configuration for production
Minimal sampling to reduce overhead while still capturing the most critical allocation patterns.
Sourcepub fn leak_detection() -> Self
pub fn leak_detection() -> Self
Creates configuration for memory leak detection
Optimized to catch large allocations and allocation patterns that might indicate memory leaks.
Sourcepub fn demo() -> Self
pub fn demo() -> Self
Creates configuration for demonstrations and testing
Maximum sampling rates to ensure all data is visible in demos and tests. Not suitable for production due to very high performance overhead.
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Validates configuration parameters
Ensures all rates are between 0.0 and 1.0 and thresholds are reasonable.
Sourcepub fn base_sampling_rate(&self, size: usize) -> f64
pub fn base_sampling_rate(&self, size: usize) -> f64
Calculates expected sampling rate for given allocation size
Returns the base sampling rate before frequency adjustments.
Sourcepub fn frequency_multiplier(&self, frequency: u64) -> f64
pub fn frequency_multiplier(&self, frequency: u64) -> f64
Calculates frequency multiplier for sampling boost
High-frequency allocations get increased sampling rates to identify performance hotspots.
Trait Implementations§
Source§impl Clone for SamplingConfig
impl Clone for SamplingConfig
Source§fn clone(&self) -> SamplingConfig
fn clone(&self) -> SamplingConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for SamplingConfig
impl Debug for SamplingConfig
Auto Trait Implementations§
impl Freeze for SamplingConfig
impl RefUnwindSafe for SamplingConfig
impl Send for SamplingConfig
impl Sync for SamplingConfig
impl Unpin for SamplingConfig
impl UnwindSafe for SamplingConfig
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> 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