pub struct DefragPrevention { /* private fields */ }Expand description
Rolling defrag-prevention estimate with hysteresis (mirror of upstream
xet-data defrag_prevention.rs).
Tracks the average number of chunks per dedup range over the last
DEFRAG_NUM_RANGES_WINDOW ranges and allows dedup only when the average
is above an effective threshold that toggles between
min_chunks_per_range and min_chunks_per_range × hysteresis_factor
(hysteresis factor < 1.0).
Implementations§
Source§impl DefragPrevention
impl DefragPrevention
Sourcepub fn new(
window_size: usize,
min_chunks_per_range: f32,
hysteresis_factor: f32,
) -> Self
pub fn new( window_size: usize, min_chunks_per_range: f32, hysteresis_factor: f32, ) -> Self
Creates a defrag-prevention tracker.
window_size is the number of ranges in the rolling estimate,
min_chunks_per_range the low dedup threshold, and hysteresis_factor
(< 1.0) the multiplier for the hysteresis band.
Sourcepub const fn window_size(&self) -> usize
pub const fn window_size(&self) -> usize
Returns the configured rolling window size in ranges.
Sourcepub const fn min_chunks_per_range(&self) -> f32
pub const fn min_chunks_per_range(&self) -> f32
Returns the configured minimum chunks per range threshold.
Sourcepub const fn hysteresis_factor(&self) -> f32
pub const fn hysteresis_factor(&self) -> f32
Returns the configured hysteresis factor.
Sourcepub fn increment_last_range_in_fragmentation_estimate(&mut self, nchunks: usize)
pub fn increment_last_range_in_fragmentation_estimate(&mut self, nchunks: usize)
Adds nchunks to the currently-last range in the estimate.
Sourcepub fn add_range_to_fragmentation_estimate(&mut self, nchunks: usize)
pub fn add_range_to_fragmentation_estimate(&mut self, nchunks: usize)
Adds a new range with nchunks chunks to the rolling estimate, evicting
the oldest range once the window is full.
Sourcepub fn rolling_chunks_per_range(&self) -> Option<f32>
pub fn rolling_chunks_per_range(&self) -> Option<f32>
Returns the rolling average chunks-per-range, or None until the window
is full.
Sourcepub fn allow_dedup_on_next_range(&mut self, dedup_range_size: usize) -> bool
pub fn allow_dedup_on_next_range(&mut self, dedup_range_size: usize) -> bool
Returns whether dedup should be allowed against the next range of
dedup_range_size chunks, updating the hysteresis threshold.
Trait Implementations§
Source§impl Clone for DefragPrevention
impl Clone for DefragPrevention
Source§impl Debug for DefragPrevention
impl Debug for DefragPrevention
Auto Trait Implementations§
impl Freeze for DefragPrevention
impl RefUnwindSafe for DefragPrevention
impl Send for DefragPrevention
impl Sync for DefragPrevention
impl Unpin for DefragPrevention
impl UnsafeUnpin for DefragPrevention
impl UnwindSafe for DefragPrevention
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> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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