userver: utils::statistics::StripedRateCounter Class Reference
Loading...
Searching...
No Matches
utils::statistics::StripedRateCounter Class Referencefinal

#include <userver/utils/statistics/striped_rate_counter.hpp>

Detailed Description

Atomic counter of type Rate with relaxed memory ordering, increased memory consumption and decreased contention.

This class is represented as Rate metric when serializing to statistics.

Differences from utils::statistics::RateCounter:

  1. StripedRateCounter takes 8 * N_CORES memory, while RateCounter is just a single atomic.
  2. StripedRateCounter uses split counters on x86_64, which results in perfect performance even under heavy concurrent usage.

Use StripedRateCounter instead of RateCounter sparingly, in places where a lot of threads are supposed to be hammering on the same metrics.

Definition at line 31 of file striped_rate_counter.hpp.

Public Types

using ValueType = Rate
 

Public Member Functions

 StripedRateCounter (Rate desired)
 
 StripedRateCounter (Rate::ValueType desired)
 
 StripedRateCounter (const StripedRateCounter &other)
 
StripedRateCounteroperator= (const StripedRateCounter &other) noexcept
 
StripedRateCounteroperator= (Rate desired) noexcept
 
void Store (Rate desired) noexcept
 
Rate Load () const noexcept
 
void Add (Rate arg) noexcept
 
StripedRateCounteroperator++ () noexcept
 
StripedRateCounteroperator+= (Rate arg) noexcept
 
StripedRateCounteroperator+= (const StripedRateCounter &arg) noexcept
 

Member Typedef Documentation

◆ ValueType

Constructor & Destructor Documentation

◆ StripedRateCounter() [1/3]

utils::statistics::StripedRateCounter::StripedRateCounter ( Rate desired)
inlineexplicit

Definition at line 37 of file striped_rate_counter.hpp.

◆ StripedRateCounter() [2/3]

utils::statistics::StripedRateCounter::StripedRateCounter ( Rate::ValueType desired)
inlineexplicit

Definition at line 39 of file striped_rate_counter.hpp.

◆ StripedRateCounter() [3/3]

utils::statistics::StripedRateCounter::StripedRateCounter ( const StripedRateCounter & other)
inline

Definition at line 41 of file striped_rate_counter.hpp.

Member Function Documentation

◆ Add()

void utils::statistics::StripedRateCounter::Add ( Rate arg)
inlinenoexcept

Definition at line 59 of file striped_rate_counter.hpp.

◆ Load()

Rate utils::statistics::StripedRateCounter::Load ( ) const
inlinenoexcept

Definition at line 57 of file striped_rate_counter.hpp.

◆ operator++()

StripedRateCounter & utils::statistics::StripedRateCounter::operator++ ( )
inlinenoexcept

Definition at line 61 of file striped_rate_counter.hpp.

◆ operator+=() [1/2]

StripedRateCounter & utils::statistics::StripedRateCounter::operator+= ( const StripedRateCounter & arg)
inlinenoexcept

Definition at line 71 of file striped_rate_counter.hpp.

◆ operator+=() [2/2]

StripedRateCounter & utils::statistics::StripedRateCounter::operator+= ( Rate arg)
inlinenoexcept

Definition at line 66 of file striped_rate_counter.hpp.

◆ operator=() [1/2]

StripedRateCounter & utils::statistics::StripedRateCounter::operator= ( const StripedRateCounter & other)
inlinenoexcept

Definition at line 43 of file striped_rate_counter.hpp.

◆ operator=() [2/2]

StripedRateCounter & utils::statistics::StripedRateCounter::operator= ( Rate desired)
inlinenoexcept

Definition at line 50 of file striped_rate_counter.hpp.

◆ Store()

void utils::statistics::StripedRateCounter::Store ( Rate desired)
inlinenoexcept

Definition at line 55 of file striped_rate_counter.hpp.


The documentation for this class was generated from the following file: