Skip to main content

PageCacheMetrics

Struct PageCacheMetrics 

Source
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

Source

pub fn new() -> Arc<Self> ⓘ

Creates new metrics.

Source

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.

Source

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.

Source

pub fn snapshot(&self) -> PageCacheSnapshot

Returns a snapshot of the statistics.

Trait Implementations§

Source§

impl Debug for PageCacheMetrics

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PageCacheMetrics

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.