pub struct PageCacheMetrics { /* private fields */ }Expand description
Page cache statistics.
Each thread has its own page cache, see crate::set_page_cache_size.
The cache reports to the metrics that are current on its thread, see
PageCacheMetrics::current. Statistics are updated with relaxed atomics,
a snapshot is not a consistent cut across all fields.
Updates are a plain load and store, not an atomic read-modify-write, so
metrics must be updated by one thread at a time. If the same metrics are
installed on several threads with PageCacheMetrics::set_current,
concurrent updates can be lost, counters undercount and the pages and
bytes gauges drift permanently.
A page released on another thread goes to the cache of that thread, so allocations and releases of the same page can be reported to different metrics.
Implementations§
Source§impl PageCacheMetrics
impl PageCacheMetrics
Sourcepub fn current() -> Arc<Self> ⓘ
pub fn current() -> Arc<Self> ⓘ
Returns the metrics of the current thread’s page cache.
Each thread has its own metrics, created with the cache, unless other
metrics were installed with PageCacheMetrics::set_current.
Sourcepub fn set_current(metrics: Arc<Self>)
pub fn set_current(metrics: Arc<Self>)
Installs metrics as the metrics of the current thread’s page cache.
The pages held by the cache are moved from the previous metrics to
metrics. Metrics must not be current on more than one thread at a
time, updates are not atomic read-modify-writes.
Sourcepub fn snapshot(&self) -> PageCacheSnapshot
pub fn snapshot(&self) -> PageCacheSnapshot
Returns a snapshot of the statistics.