[RocksDB] Expose compaction stalls via db_statistics

Test Plan: make check

Reviewers: dhruba, haobo

Reviewed By: dhruba

CC: leveldb

Differential Revision: https://reviews.facebook.net/D10575
main
Abhishek Kona 12 years ago
parent d98e56315d
commit 8d58ecdc29
  1. 13
      db/db_impl.cc
  2. 9
      include/leveldb/statistics.h

@ -2183,6 +2183,7 @@ Status DBImpl::MakeRoomForWrite(bool force) {
uint64_t t1 = env_->NowMicros();
env_->SleepForMicroseconds(1000);
uint64_t delayed = env_->NowMicros() - t1;
RecordTick(options_.statistics, STALL_L0_SLOWDOWN_MICROS, delayed);
stall_level0_slowdown_ += delayed;
allow_delay = false; // Do not delay a single write more than once
//Log(options_.info_log,
@ -2204,7 +2205,9 @@ Status DBImpl::MakeRoomForWrite(bool force) {
Log(options_.info_log, "wait for memtable compaction...\n");
uint64_t t1 = env_->NowMicros();
bg_cv_.Wait();
stall_memtable_compaction_ += env_->NowMicros() - t1;
const uint64_t stall = env_->NowMicros() -t1;
RecordTick(options_.statistics, STALL_MEMTABLE_COMPACTION_MICROS, stall);
stall_memtable_compaction_ += stall;
} else if (versions_->NumLevelFiles(0) >=
options_.level0_stop_writes_trigger) {
// There are too many level-0 files.
@ -2212,7 +2215,9 @@ Status DBImpl::MakeRoomForWrite(bool force) {
uint64_t t1 = env_->NowMicros();
Log(options_.info_log, "wait for fewer level0 files...\n");
bg_cv_.Wait();
stall_level0_num_files_ += env_->NowMicros() - t1;
const uint64_t stall = env_->NowMicros() - t1;
RecordTick(options_.statistics, STALL_L0_NUM_FILES_MICROS, stall);
stall_level0_num_files_ += stall;
} else if (
allow_rate_limit_delay &&
options_.rate_limit > 1.0 &&
@ -2225,7 +2230,9 @@ Status DBImpl::MakeRoomForWrite(bool force) {
uint64_t delayed = env_->NowMicros() - t1;
stall_leveln_slowdown_[max_level] += delayed;
// Make sure the following value doesn't round to zero.
rate_limit_delay_millis += std::max((delayed / 1000), (uint64_t) 1);
uint64_t rate_limit = std::max((delayed / 1000), (uint64_t) 1);
rate_limit_delay_millis += rate_limit;
RecordTick(options_.statistics, RATE_LIMIT_DELAY_MILLIS, rate_limit);
if (rate_limit_delay_millis >=
(unsigned)options_.rate_limit_delay_milliseconds) {
allow_rate_limit_delay = false;

@ -40,7 +40,14 @@ enum Tickers {
NO_FILE_CLOSES = 10,
NO_FILE_OPENS = 11,
NO_FILE_ERRORS = 12,
TICKER_ENUM_MAX = 13,
// Time system had to wait to do LO-L1 compactions
STALL_L0_SLOWDOWN_MICROS = 13,
// Time system had to wait to move memtable to L1.
STALL_MEMTABLE_COMPACTION_MICROS = 14,
// write throttle because of too many files in L0
STALL_L0_NUM_FILES_MICROS = 15,
RATE_LIMIT_DELAY_MILLIS = 16,
TICKER_ENUM_MAX = 17
};

Loading…
Cancel
Save