Relax memory order for faster tickers
Summary: The default behavior for atomic operations is sequentially consistent ordering which is not needed for simple counters (see: http://en.cppreference.com/w/cpp/atomic/memory_order). Change the memory order to std::memory_order_relaxed for better performance. Test Plan: make clean all check Reviewers: rven, anthony, yhchiang, aekmekji, sdong, MarkCallaghan, igor Reviewed By: igor Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D46953
This commit is contained in:
parent
4886073174
commit
df22e2fb71
@ -62,7 +62,7 @@ void StatisticsImpl::setTickerCount(uint32_t tickerType, uint64_t count) {
|
|||||||
tickerType < INTERNAL_TICKER_ENUM_MAX :
|
tickerType < INTERNAL_TICKER_ENUM_MAX :
|
||||||
tickerType < TICKER_ENUM_MAX);
|
tickerType < TICKER_ENUM_MAX);
|
||||||
if (tickerType < TICKER_ENUM_MAX || enable_internal_stats_) {
|
if (tickerType < TICKER_ENUM_MAX || enable_internal_stats_) {
|
||||||
tickers_[tickerType].value = count;
|
tickers_[tickerType].value.store(count, std::memory_order_relaxed);
|
||||||
}
|
}
|
||||||
if (stats_ && tickerType < TICKER_ENUM_MAX) {
|
if (stats_ && tickerType < TICKER_ENUM_MAX) {
|
||||||
stats_->setTickerCount(tickerType, count);
|
stats_->setTickerCount(tickerType, count);
|
||||||
@ -75,7 +75,7 @@ void StatisticsImpl::recordTick(uint32_t tickerType, uint64_t count) {
|
|||||||
tickerType < INTERNAL_TICKER_ENUM_MAX :
|
tickerType < INTERNAL_TICKER_ENUM_MAX :
|
||||||
tickerType < TICKER_ENUM_MAX);
|
tickerType < TICKER_ENUM_MAX);
|
||||||
if (tickerType < TICKER_ENUM_MAX || enable_internal_stats_) {
|
if (tickerType < TICKER_ENUM_MAX || enable_internal_stats_) {
|
||||||
tickers_[tickerType].value += count;
|
tickers_[tickerType].value.fetch_add(count, std::memory_order_relaxed);
|
||||||
}
|
}
|
||||||
if (stats_ && tickerType < TICKER_ENUM_MAX) {
|
if (stats_ && tickerType < TICKER_ENUM_MAX) {
|
||||||
stats_->recordTick(tickerType, count);
|
stats_->recordTick(tickerType, count);
|
||||||
|
Loading…
Reference in New Issue
Block a user