pub struct PrefetchPredictor {
compute_durations: VecDeque<u64>,
loading_durations: VecDeque<u64>,
max_history: usize,
prefetch_lead_ns: u64,
}Expand description
Tracks phase durations to predict when to trigger prefetch.
Fields§
§compute_durations: VecDeque<u64>Recent GpuCompute phase durations (ns).
loading_durations: VecDeque<u64>Recent DataLoading phase durations (ns).
max_history: usizeMaximum history size.
prefetch_lead_ns: u64How far before predicted compute end to trigger prefetch (ns).
Implementations§
Source§impl PrefetchPredictor
impl PrefetchPredictor
pub fn new(max_history: usize, prefetch_lead_ns: u64) -> Self
Sourcepub fn record_compute(&mut self, duration_ns: u64)
pub fn record_compute(&mut self, duration_ns: u64)
Record a completed GpuCompute phase duration.
Sourcepub fn record_loading(&mut self, duration_ns: u64)
pub fn record_loading(&mut self, duration_ns: u64)
Record a completed DataLoading phase duration.
Sourcepub fn predicted_compute_ns(&self) -> Option<u64>
pub fn predicted_compute_ns(&self) -> Option<u64>
Predict the next GpuCompute duration using exponential moving average.
Sourcepub fn predicted_loading_ns(&self) -> Option<u64>
pub fn predicted_loading_ns(&self) -> Option<u64>
Predict the next DataLoading duration.
Sourcepub fn should_prefetch(&self, elapsed_compute_ns: u64) -> bool
pub fn should_prefetch(&self, elapsed_compute_ns: u64) -> bool
Should we trigger prefetch now? Call this periodically during GpuCompute phase with elapsed time.
Sourcepub fn overlap_efficiency(&self) -> f64
pub fn overlap_efficiency(&self) -> f64
Calculate the overlap efficiency. 1.0 = perfect overlap (data ready exactly when GPU finishes) <1.0 = GPU had to wait for data
1.0 = data was ready before GPU finished (ideal)
Auto Trait Implementations§
impl Freeze for PrefetchPredictor
impl RefUnwindSafe for PrefetchPredictor
impl Send for PrefetchPredictor
impl Sync for PrefetchPredictor
impl Unpin for PrefetchPredictor
impl UnwindSafe for PrefetchPredictor
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
Mutably borrows from an owned value. Read more