From d98e56315d308c2b427b62b5dc8b55d91ad36428 Mon Sep 17 00:00:00 2001 From: Abhishek Kona Date: Fri, 10 May 2013 13:19:39 -0700 Subject: [PATCH] [RocksDB] Make Ticker Atomic Summary: Our ticker was not atomic. This was based on the assumption that we will increment counts at places only protected by Mutex. This is hard to program for and easy to make mistakes (mutex may be held a few layers above etc). Also this increases the instructions executed when the mutex is held. Test Plan: make check Reviewers: haobo, dhruba Reviewed By: dhruba CC: leveldb Differential Revision: https://reviews.facebook.net/D10569 --- include/leveldb/statistics.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/leveldb/statistics.h b/include/leveldb/statistics.h index 427cbd373..5686b9416 100644 --- a/include/leveldb/statistics.h +++ b/include/leveldb/statistics.h @@ -5,6 +5,7 @@ #ifndef STORAGE_LEVELDB_INCLUDE_STATISTICS_H_ #define STORAGE_LEVELDB_INCLUDE_STATISTICS_H_ +#include #include #include #include @@ -106,8 +107,7 @@ class Ticker { } private: - uint64_t count_; - + std::atomic_uint_fast64_t count_; }; // Analyze the performance of a db