mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
stat's collection in leveldb
Summary:
Prototype stat's collection. Diff is a good estimate of what
the final code will look like.
A few assumptions :
* Used a global static instance of the statistics object. Plan to pass
it to each internal function. Static allows metrics only at app
level.
* In the Ticker's do not do any locking. Depend on the mutex at each
function of LevelDB. If we ever remove the mutex, we should change
here too. The other option is use atomic objects anyways as there
won't be any contention as they will be always acquired only by one
thread.
* The counters are dumb, increment through lifecycle. Plan to use ods
etc to get last5min stat etc.
Test Plan:
made changes in db_bench
Ran ./db_bench --statistics=1 --num=10000 --cache_size=5000
This will print the cache hit/miss stats.
Reviewers: dhruba, heyongqiang
Differential Revision: https://reviews.facebook.net/D6441
This commit is contained in:
@@ -7,9 +7,43 @@
|
||||
|
||||
namespace leveldb {
|
||||
|
||||
/**
|
||||
* Keep adding ticker's here.
|
||||
* Any ticker should have a value less than TICKER_ENUM_MAX.
|
||||
* Add a new ticker by assigning it the current value of TICKER_ENUM_MAX
|
||||
* And incrementing TICKER_ENUM_MAX.
|
||||
*/
|
||||
enum Tickers {
|
||||
BLOCK_CACHE_MISS = 0,
|
||||
BLOCK_CACHE_HIT = 1,
|
||||
TICKER_ENUM_MAX = 2,
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A dumb ticker which keeps incrementing through its life time.
|
||||
* Not thread safe. Locking is currently managed by external leveldb lock
|
||||
*/
|
||||
class Ticker {
|
||||
public:
|
||||
Ticker() : count_(0) { }
|
||||
|
||||
inline void recordTick() {
|
||||
count_++;
|
||||
}
|
||||
|
||||
inline uint64_t getCount() {
|
||||
return count_;
|
||||
}
|
||||
|
||||
private:
|
||||
uint64_t count_;
|
||||
|
||||
};
|
||||
|
||||
// Analyze the performance of a db
|
||||
class Statistics {
|
||||
public:
|
||||
public:
|
||||
// Create an Statistics object with default values for all fields.
|
||||
Statistics() : numFileOpens_(0), numFileCloses_(0),
|
||||
numFileErrors_(0) {}
|
||||
@@ -23,12 +57,21 @@ class Statistics {
|
||||
virtual long getNumFileErrors() { return numFileErrors_;}
|
||||
virtual ~Statistics() {}
|
||||
|
||||
virtual long getTickerCount(Tickers tickerType) = 0;
|
||||
virtual void recordTick(Tickers tickerType) = 0;
|
||||
|
||||
protected:
|
||||
long numFileOpens_;
|
||||
long numFileCloses_;
|
||||
long numFileErrors_;
|
||||
};
|
||||
|
||||
// Ease of Use functions
|
||||
inline void RecordTick(Statistics* const statistics, Tickers ticker) {
|
||||
if (statistics != NULL) {
|
||||
statistics->recordTick(ticker);
|
||||
}
|
||||
};
|
||||
} // namespace leveldb
|
||||
|
||||
#endif // STORAGE_LEVELDB_INCLUDE_STATISTICS_H_
|
||||
|
||||
Reference in New Issue
Block a user