pub struct StorageAccessLog {
pub entries: Vec<AccessLogEntry>,
pub next_entry_id: u64,
pub config: LogConfig,
pub cumulative_ops: HashMap<LogOperation, u64>,
pub cumulative_read_bytes: u64,
pub cumulative_write_bytes: u64,
pub seen_blocks: HashSet<u64>,
}Expand description
Append-only access log for storage operations.
Keeps a sliding window of at most config.max_entries entries; older
entries are evicted FIFO. Cumulative statistics survive eviction.
Fields§
§entries: Vec<AccessLogEntry>Sliding window of log entries.
next_entry_id: u64Monotonically increasing counter used to assign AccessLogEntry::entry_id.
config: LogConfigActive configuration.
cumulative_ops: HashMap<LogOperation, u64>Cumulative per-operation counts (never decremented on eviction).
cumulative_read_bytes: u64Total bytes read, cumulative.
cumulative_write_bytes: u64Total bytes written, cumulative.
seen_blocks: HashSet<u64>Set of every block ID ever logged.
Implementations§
Source§impl StorageAccessLog
impl StorageAccessLog
Sourcepub fn new(config: LogConfig) -> Self
pub fn new(config: LogConfig) -> Self
Create a new StorageAccessLog with the provided configuration.
Sourcepub fn log(
&mut self,
block_id: u64,
cid: String,
operation: LogOperation,
size_bytes: u64,
tick: u64,
peer_id: Option<String>,
)
pub fn log( &mut self, block_id: u64, cid: String, operation: LogOperation, size_bytes: u64, tick: u64, peer_id: Option<String>, )
Record a storage operation.
If the sliding window is full (entries.len() >= max_entries) the
oldest entry is removed before the new one is appended.
Sourcepub fn detect_pattern(&self, current_tick: u64) -> AccessPattern
pub fn detect_pattern(&self, current_tick: u64) -> AccessPattern
Detect the access pattern in the recent window.
Priority order:
- BurstWrite — many writes in the last
burst_window_ticksticks. - Repeated — any block ID appears ≥ 3 times in the last 10 reads.
- Sequential — the last 5 reads have strictly increasing block IDs.
- Random — fallthrough.
Sourcepub fn entries_for_block(&self, block_id: u64) -> Vec<&AccessLogEntry>
pub fn entries_for_block(&self, block_id: u64) -> Vec<&AccessLogEntry>
Return all entries for a specific block ID, in log order.
Sourcepub fn entries_in_range(
&self,
from_tick: u64,
to_tick: u64,
) -> Vec<&AccessLogEntry>
pub fn entries_in_range( &self, from_tick: u64, to_tick: u64, ) -> Vec<&AccessLogEntry>
Return all entries whose tick falls in [from_tick, to_tick] (inclusive).
Sourcepub fn stats(&self) -> AccessLogStats
pub fn stats(&self) -> AccessLogStats
Snapshot of cumulative statistics.
Auto Trait Implementations§
impl Freeze for StorageAccessLog
impl RefUnwindSafe for StorageAccessLog
impl Send for StorageAccessLog
impl Sync for StorageAccessLog
impl Unpin for StorageAccessLog
impl UnsafeUnpin for StorageAccessLog
impl UnwindSafe for StorageAccessLog
Blanket Implementations§
impl<T> Allocation for T
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