pub struct ThreadLocalCounters { /* private fields */ }Expand description
Thread-local counter buffer (Kaizen: eliminates atomic contention)
Instead of atomic increments on every block hit, counters are buffered locally and flushed periodically. This dramatically reduces cache coherence traffic in parallel coverage collection.
Implementations§
Source§impl ThreadLocalCounters
impl ThreadLocalCounters
Sourcepub fn new(block_count: usize) -> Self
pub fn new(block_count: usize) -> Self
Create new thread-local counters for the given number of blocks
Uses a default flush threshold of 1000 blocks.
Sourcepub fn with_flush_threshold(block_count: usize, threshold: usize) -> Self
pub fn with_flush_threshold(block_count: usize, threshold: usize) -> Self
Create with a custom flush threshold
Lower thresholds mean more frequent flushes (more accurate but slower). Higher thresholds mean fewer flushes (faster but less accurate intermediate state).
Sourcepub fn increment(&mut self, block: BlockId)
pub fn increment(&mut self, block: BlockId)
Increment counter locally (no atomic, no cache coherence traffic)
This is the hot path - must be as fast as possible.
Sourcepub fn get(&self, block: BlockId) -> u64
pub fn get(&self, block: BlockId) -> u64
Get the current local count for a block (before flush)
Sourcepub fn flush(&mut self) -> Vec<u64>
pub fn flush(&mut self) -> Vec<u64>
Flush local counters and return the counts
Returns the accumulated counts and resets the local buffer.
Sourcepub fn flush_count(&self) -> usize
pub fn flush_count(&self) -> usize
Get the number of times flush has been called
Sourcepub fn block_count(&self) -> usize
pub fn block_count(&self) -> usize
Get the number of blocks being tracked
Sourcepub fn has_pending(&self) -> bool
pub fn has_pending(&self) -> bool
Check if any blocks have been hit since last flush
Sourcepub fn flush_threshold(&self) -> usize
pub fn flush_threshold(&self) -> usize
Get the flush threshold
Trait Implementations§
Source§impl Debug for ThreadLocalCounters
impl Debug for ThreadLocalCounters
Auto Trait Implementations§
impl Freeze for ThreadLocalCounters
impl RefUnwindSafe for ThreadLocalCounters
impl Send for ThreadLocalCounters
impl Sync for ThreadLocalCounters
impl Unpin for ThreadLocalCounters
impl UnsafeUnpin for ThreadLocalCounters
impl UnwindSafe for ThreadLocalCounters
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
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().