MDEV-25281: Switch to use non-atomic (vs atomic) distributed counter to

track page-access counter

As part of MDEV-21212, n_page_gets that is meant to track page access,
is ported to use distributed counter that default uses atomic sub-counters.

n_page_gets originally was a non-atomic counter that represented an approximate
value of pages tracked. Using the said analogy it doesn't need to be
an atomic distributed counter.

This patch introduces an interface that allows distributed counter to be
used with atomic and non-atomic sub-counter (through template) and also
port n_page_gets to use non-atomic distributed counter using the said
updated interface.
This commit is contained in:
Krunal Bauskar 2021-03-29 11:51:00 +08:00 committed by Marko Mäkelä
commit 0f6f72965b
3 changed files with 27 additions and 17 deletions

View file

@ -45,6 +45,7 @@ public:
Type operator=(const Type val)
{ m.store(val, std::memory_order_relaxed); return val; }
Type operator=(const Atomic_relaxed<Type> &rhs) { return *this= Type{rhs}; }
Type operator+=(const Type i) { return fetch_add(i); }
Type fetch_add(const Type i, std::memory_order o= std::memory_order_relaxed)
{ return m.fetch_add(i, o); }
Type fetch_sub(const Type i, std::memory_order o= std::memory_order_relaxed)