pub struct AdaptiveController { /* private fields */ }Expand description
Per-region adaptive controller: tracks per-2-MiB-block fault rate and signals when a region should step down from 2 MiB to 16 KiB tracking.
Per 16-snapshots.md § 4.2 the threshold is “32 faults / 100 ms / 2 MiB block” — per-block, not aggregate across the region. A uniform-low-rate workload that touches many blocks must not trigger step-down; only a workload concentrated in some block must.
Implementations§
Source§impl AdaptiveController
impl AdaptiveController
Sourcepub fn new(block_count: u64) -> Self
pub fn new(block_count: u64) -> Self
Build a controller with the spec-default threshold (32 faults / 100 ms /
2 MiB block) for block_count 2-MiB blocks.
Sourcepub fn with_threshold(block_count: u64, threshold: u32) -> Self
pub fn with_threshold(block_count: u64, threshold: u32) -> Self
Build with a custom threshold (used by [squib].snapshot.dirty_step_down_threshold
in user config — § 4.2).
Sourcepub fn granule(&self) -> TrackingGranule
pub fn granule(&self) -> TrackingGranule
Active granule.
Sourcepub fn record_fault(&self, block_idx: u64)
pub fn record_fault(&self, block_idx: u64)
Increment the fault counter for the given coarse block. Called by the dirty-tracking exit handler on every page fault re-grant.
Out-of-range block_idx is silently ignored (defence-in-depth — the bitmap
rejects out-of-range pages too).
Sourcepub fn tick(&self) -> TrackingGranule
pub fn tick(&self) -> TrackingGranule
Check and (if we’ve crossed a window boundary) decide whether the granule should step down. Returns the (possibly-changed) active granule.
Step-down fires when any block’s fault counter exceeded the threshold in the last window. Step-down is one-way for the lifetime of one tracking session; ramping back up to 2 MiB requires a clean checkpoint.