pub struct ShapeHistory { /* private fields */ }Expand description
Bounded ring buffer of recent dispatch fingerprints. The
predictor looks back at most MAX_HISTORY entries.
Implementations§
Source§impl ShapeHistory
impl ShapeHistory
Sourcepub fn record(&mut self, fingerprint: ShapeFingerprint)
pub fn record(&mut self, fingerprint: ShapeFingerprint)
Record a dispatch fingerprint. The predictor uses the most
recent MAX_HISTORY entries to predict the next.
Sourcepub fn latest(&self) -> Option<&ShapeFingerprint>
pub fn latest(&self) -> Option<&ShapeFingerprint>
Most recent fingerprint, or None if history is empty.
Sourcepub fn contains(&self, fingerprint: &ShapeFingerprint) -> bool
pub fn contains(&self, fingerprint: &ShapeFingerprint) -> bool
True when the retained history window contains fingerprint.
This lets backend-side prediction caches evict cloned predicted programs that can no longer be predicted by the bounded history.
Sourcepub fn predict_next(&self) -> Option<ShapeFingerprint>
pub fn predict_next(&self) -> Option<ShapeFingerprint>
Predict the next dispatch fingerprint. Returns None when
the history is too sparse or no pattern matches.
Strategy:
- If the last two entries are equal, predict another repeat.
- Otherwise, look for the smallest cycle length
Nsuch that every retained entry with an entryNpositions earlier matches it. This predicts partial cycles as soon as one lag agrees, e.g.A,B,C,A,B -> C, instead of waiting forA,B,C,A,B,C. - No prediction.
Trait Implementations§
Source§impl Clone for ShapeHistory
impl Clone for ShapeHistory
Source§fn clone(&self) -> ShapeHistory
fn clone(&self) -> ShapeHistory
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ShapeHistory
impl Debug for ShapeHistory
Auto Trait Implementations§
impl Freeze for ShapeHistory
impl RefUnwindSafe for ShapeHistory
impl Send for ShapeHistory
impl Sync for ShapeHistory
impl Unpin for ShapeHistory
impl UnsafeUnpin for ShapeHistory
impl UnwindSafe for ShapeHistory
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