mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
Add counters to count gets and writes
Summary: Add Tickers to count Write's and Get's Test Plan: make check Reviewers: dhruba, chip Reviewed By: dhruba CC: leveldb Differential Revision: https://reviews.facebook.net/D7977
This commit is contained in:
@@ -1875,6 +1875,7 @@ Status DBImpl::Get(const ReadOptions& options,
|
||||
mem->Unref();
|
||||
imm.UnrefAll();
|
||||
current->Unref();
|
||||
RecordTick(options_.statistics, NUMBER_KEYS_READ);
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -1930,7 +1931,10 @@ Status DBImpl::Write(const WriteOptions& options, WriteBatch* my_batch) {
|
||||
if (status.ok() && my_batch != NULL) { // NULL batch is for compactions
|
||||
WriteBatch* updates = BuildBatchGroup(&last_writer);
|
||||
WriteBatchInternal::SetSequence(updates, last_sequence + 1);
|
||||
last_sequence += WriteBatchInternal::Count(updates);
|
||||
int my_batch_count = WriteBatchInternal::Count(updates);
|
||||
last_sequence += my_batch_count;
|
||||
// Record statistics
|
||||
RecordTick(options_.statistics, NUMBER_KEYS_WRITTEN, my_batch_count);
|
||||
|
||||
// Add to log and apply to memtable. We can release the lock
|
||||
// during this phase since &w is currently responsible for logging
|
||||
@@ -1977,7 +1981,6 @@ Status DBImpl::Write(const WriteOptions& options, WriteBatch* my_batch) {
|
||||
if (!writers_.empty()) {
|
||||
writers_.front()->cv.Signal();
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,9 +35,9 @@ class DBStatistics: public Statistics {
|
||||
return allTickers_[tickerType].getCount();
|
||||
}
|
||||
|
||||
void recordTick(Tickers tickerType) {
|
||||
void recordTick(Tickers tickerType, uint64_t count) {
|
||||
assert(tickerType < TICKER_ENUM_MAX);
|
||||
allTickers_[tickerType].recordTick();
|
||||
allTickers_[tickerType].recordTick(count);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -252,6 +252,8 @@ struct Options {
|
||||
int max_grandparent_overlap_factor;
|
||||
|
||||
// If non-null, then we should collect metrics about database operations
|
||||
// Statistics objects should not be shared between DB instances as
|
||||
// it does not use any locks to prevent concurrent updates.
|
||||
Statistics* statistics;
|
||||
|
||||
// If true, then the contents of data files are not synced
|
||||
|
||||
@@ -24,7 +24,11 @@ enum Tickers {
|
||||
COMPACTION_KEY_DROP_NEWER_ENTRY = 3, // key was written with a newer value.
|
||||
COMPACTION_KEY_DROP_OBSOLETE = 4, // The key is obsolete.
|
||||
COMPACTION_KEY_DROP_USER = 5, // user compaction function has dropped the key.
|
||||
TICKER_ENUM_MAX = 6,
|
||||
// Number of keys written to the database via the Put and Write call's
|
||||
NUMBER_KEYS_WRITTEN = 6,
|
||||
// Number of Keys read,
|
||||
NUMBER_KEYS_READ = 7,
|
||||
TICKER_ENUM_MAX = 8,
|
||||
};
|
||||
|
||||
|
||||
@@ -40,6 +44,9 @@ class Ticker {
|
||||
count_++;
|
||||
}
|
||||
|
||||
inline void recordTick(int count) {
|
||||
count_ += count;
|
||||
}
|
||||
inline uint64_t getCount() {
|
||||
return count_;
|
||||
}
|
||||
@@ -66,7 +73,7 @@ class Statistics {
|
||||
virtual ~Statistics() {}
|
||||
|
||||
virtual long getTickerCount(Tickers tickerType) = 0;
|
||||
virtual void recordTick(Tickers tickerType) = 0;
|
||||
virtual void recordTick(Tickers tickerType, uint64_t count = 0) = 0;
|
||||
|
||||
protected:
|
||||
long numFileOpens_;
|
||||
@@ -75,11 +82,13 @@ class Statistics {
|
||||
};
|
||||
|
||||
// Ease of Use functions
|
||||
inline void RecordTick(Statistics* const statistics, Tickers ticker) {
|
||||
inline void RecordTick(Statistics* const statistics,
|
||||
Tickers ticker,
|
||||
uint64_t count = 1) {
|
||||
if (statistics != NULL) {
|
||||
statistics->recordTick(ticker);
|
||||
statistics->recordTick(ticker, count);
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace leveldb
|
||||
|
||||
#endif // STORAGE_LEVELDB_INCLUDE_STATISTICS_H_
|
||||
|
||||
Reference in New Issue
Block a user