pub struct BounceTracker { /* private fields */ }Implementations§
Source§impl BounceTracker
impl BounceTracker
pub fn new() -> BounceTracker
pub fn next_seq(&mut self) -> u64
pub fn set_seq(&mut self, seq: u64)
pub fn record_read( &mut self, path: &str, mode: &str, tokens_sent: usize, original_tokens: usize, )
Sourcepub fn flush_pending(&mut self)
pub fn flush_pending(&mut self)
Commit every provisional bounce now, regardless of its window. Used at process shutdown so a bounce detected shortly before exit is not lost.
Sourcepub fn pending_bounces(&self) -> usize
pub fn pending_bounces(&self) -> usize
Provisional bounces still waiting for their edit window to pass.
Sourcepub fn record_shell_read(&mut self, path: &str, view: ReadView)
pub fn record_shell_read(&mut self, path: &str, view: ReadView)
A shell read of path (cat, head, sed -n, …). A full read can
complete a correction of a preceding compressed view; a partial one
never does. Either way it becomes the path’s newest read, so a second
cat cannot book the same correction twice.
Sourcepub fn record_expansion(&mut self, source: Option<&str>, wasted_tokens: usize)
pub fn record_expansion(&mut self, source: Option<&str>, wasted_tokens: usize)
Records an explicit archive/context expansion as a quality bounce.
Unlike a full file re-read, ctx_expand may address a content handle
rather than a path, so it cannot always be inferred by detect_bounce.
Benchmark replay uses this method to keep the quality proxy on the same
tracker as ordinary compressed-then-full bounces.
Sourcepub fn last_read(&self, path: &str) -> Option<(bool, Option<(String, String)>)>
pub fn last_read(&self, path: &str) -> Option<(bool, Option<(String, String)>)>
The newest read of path this process still remembers: whether it
was compressed and the scope and task it ran under, so a later event
is charged to the read that caused it. None: no read is known here
(another process, or before a restart). A partial read (line window)
is precise, not lossy, so it reports false like a full read.
Sourcepub fn record_edit(&mut self, path: &str)
pub fn record_edit(&mut self, path: &str)
An edit of path. Besides exempting the full re-reads it forces, it
cancels any provisional bounce of the path still inside its edit
window: the compressed→full re-read was the read-before-edit, not a
compression failure.
pub fn should_force_full(&self, path: &str) -> bool
pub fn bounce_rate_for_extension(&self, path: &str) -> Option<f64>
pub fn total_bounces(&self) -> u64
pub fn total_wasted_tokens(&self) -> usize
pub fn adjusted_savings(&self, raw_savings: usize) -> isize
pub fn per_extension_json(&self) -> Vec<Value>
pub fn format_summary(&self) -> String
Trait Implementations§
Source§impl Debug for BounceTracker
impl Debug for BounceTracker
Source§impl Default for BounceTracker
impl Default for BounceTracker
Source§fn default() -> BounceTracker
fn default() -> BounceTracker
Auto Trait Implementations§
impl Forget for BounceTracker
impl Freeze for BounceTrackerwhere
*const u8 is !null: Freeze,
PhantomData<(String, Vec<ReadEvent>)>: Freeze,
PhantomData<(String, BounceStats)>: Freeze,
PhantomData<(String, u64)>: Freeze,
PhantomData<PendingBounce>: Freeze,
impl Move for BounceTracker
impl RefUnwindSafe for BounceTracker
impl Send for BounceTracker
impl Sync for BounceTracker
impl Unpin for BounceTracker
impl UnsafeUnpin for BounceTrackerwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<(String, Vec<ReadEvent>)>: UnsafeUnpin,
PhantomData<(String, BounceStats)>: UnsafeUnpin,
PhantomData<(String, u64)>: UnsafeUnpin,
PhantomData<PendingBounce>: UnsafeUnpin,
impl UnwindSafe for BounceTrackerwhere
HashMap<String, Vec<ReadEvent>>: UnwindSafe,
HashMap<String, BounceStats>: UnwindSafe,
HashMap<String, u64>: UnwindSafe,
RawVecInner: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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