Fix performance regression in statistics
Summary: For some reason, D15099 caused a big performance regression: https://fburl.com/16059000 After digging a bit, I figured out that the reason was that std::atomic_uint_fast64_t was allocated in an array. When I switched from an array to vector, the QPS returned to the previous level. I'm not sure why this is happening, but this diff seems to fix the performance regression. Test Plan: I ran the regression script, observed the performance going back to normal Reviewers: tnovak, kailiu, haobo Reviewed By: kailiu CC: leveldb Differential Revision: https://reviews.facebook.net/D15375
This commit is contained in:
parent
d0458469c8
commit
4e91f27c3a
@ -14,11 +14,9 @@ std::shared_ptr<Statistics> CreateDBStatistics() {
|
||||
return std::make_shared<StatisticsImpl>();
|
||||
}
|
||||
|
||||
StatisticsImpl::StatisticsImpl() {
|
||||
// Fill tickers_ with "zero". To ensure plasform indepedent, we used
|
||||
// uint_fast64_t() instead literal `0` to represent zero.
|
||||
std::fill(tickers_, tickers_ + TICKER_ENUM_MAX, uint_fast64_t());
|
||||
}
|
||||
StatisticsImpl::StatisticsImpl()
|
||||
: tickers_(TICKER_ENUM_MAX),
|
||||
histograms_(HISTOGRAM_ENUM_MAX) {}
|
||||
|
||||
StatisticsImpl::~StatisticsImpl() {}
|
||||
|
||||
|
@ -8,6 +8,9 @@
|
||||
#include "util/histogram.h"
|
||||
#include "util/mutexlock.h"
|
||||
|
||||
#include <vector>
|
||||
#include <atomic>
|
||||
|
||||
#define UNLIKELY(val) (__builtin_expect((val), 0))
|
||||
|
||||
namespace rocksdb {
|
||||
@ -25,8 +28,8 @@ class StatisticsImpl : public Statistics {
|
||||
HistogramData* const data);
|
||||
|
||||
private:
|
||||
std::atomic_uint_fast64_t tickers_[TICKER_ENUM_MAX];
|
||||
HistogramImpl histograms_[HISTOGRAM_ENUM_MAX];
|
||||
std::vector<std::atomic_uint_fast64_t> tickers_;
|
||||
std::vector<HistogramImpl> histograms_;
|
||||
};
|
||||
|
||||
// Utility functions
|
||||
|
Loading…
Reference in New Issue
Block a user