Struct AccessClock

Struct Documentation

struct AccessClock

diagnostic (analysis-only, off by default): a global monotonic “access clock” stamped on every genuine cache read, plus a per-value (keyed by canonical node hash) record of the last clock at which that value was read.

Home (root-homed) cache entries are pinned (life_c == SIZE_MAX), so their lifetime counter never drains and cannot be used to infer their genuine last use. This clock records the real thing: CacheManager::access_at (the only genuine consumer-read path — the store-return entry::access() bypasses it) calls tick() and stamps the read value’s hash into last_access_map on every hit when enabled(). The record is a global map keyed by node hash (not a per-entry field) deliberately: a batch-loop tier-B value lives on a per-block scratch cache that is destroyed at block close, so a per-entry field would be lost; the global map keeps the value’s final last-read clock across the whole run regardless of which (root or transient scratch) scope held it. Reset by the harness before a measured run. Single-threaded dry-run only. When enabled() is false every stamp site is a no-op and the eval path is left untouched.

Public Static Functions

static inline bool enabled() noexcept

One-shot env gate (SEQUANT_UT_ACCESS_CLOCK). Read once; when unset every stamp site below is inert.

static inline std::size_t &counter() noexcept
static inline std::unordered_map<std::size_t, std::size_t> &last_access_map() noexcept

hash -> final (max) clock at which a value with that hash was read.

static inline std::size_t tick() noexcept

Advance and return the clock (one genuine read == one tick).

static inline std::size_t now() noexcept

Current clock value without advancing (used to timestamp the peak).

static inline void stamp(std::size_t h) noexcept

Record a genuine read of the value with hash h at a fresh clock tick.

static inline void reset() noexcept

Clear the clock and the per-value record before a measured run.