PrefetchPredictor

Struct PrefetchPredictor 

Source
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: usize

Maximum history size.

§prefetch_lead_ns: u64

How far before predicted compute end to trigger prefetch (ns).

Implementations§

Source§

impl PrefetchPredictor

Source

pub fn new(max_history: usize, prefetch_lead_ns: u64) -> Self

Source

pub fn record_compute(&mut self, duration_ns: u64)

Record a completed GpuCompute phase duration.

Source

pub fn record_loading(&mut self, duration_ns: u64)

Record a completed DataLoading phase duration.

Source

pub fn predicted_compute_ns(&self) -> Option<u64>

Predict the next GpuCompute duration using exponential moving average.

Source

pub fn predicted_loading_ns(&self) -> Option<u64>

Predict the next DataLoading duration.

Source

pub fn should_prefetch(&self, elapsed_compute_ns: u64) -> bool

Should we trigger prefetch now? Call this periodically during GpuCompute phase with elapsed time.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more