From 8e792e5896093f8a06ff296e5b10feacc77981c6 Mon Sep 17 00:00:00 2001 From: Jim Paton Date: Mon, 5 Aug 2013 18:45:23 -0700 Subject: [PATCH] Add soft_rate_limit stats Summary: This diff adds histogram stats for soft_rate_limit stalls. It also renames the old rate_limit stats to hard_rate_limit. Test Plan: make -j32 check Reviewers: dhruba, haobo, MarkCallaghan Reviewed By: dhruba CC: leveldb Differential Revision: https://reviews.facebook.net/D12021 --- db/db_impl.cc | 16 ++++++++++------ include/leveldb/statistics.h | 8 +++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/db/db_impl.cc b/db/db_impl.cc index af92d624f..5b104cd2e 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -2541,7 +2541,7 @@ Status DBImpl::MakeRoomForWrite(bool force) { mutex_.Unlock(); uint64_t delayed; { - StopWatch sw(env_, options_.statistics, RATE_LIMIT_DELAY_COUNT); + StopWatch sw(env_, options_.statistics, HARD_RATE_LIMIT_DELAY_COUNT); env_->SleepForMicroseconds(1000); delayed = sw.ElapsedMicros(); } @@ -2567,11 +2567,15 @@ Status DBImpl::MakeRoomForWrite(bool force) { // Delay a write when the compaction score for any level is too large. // TODO: add statistics mutex_.Unlock(); - env_->SleepForMicroseconds(SlowdownAmount( - score, - options_.soft_rate_limit, - options_.hard_rate_limit) - ); + { + StopWatch sw(env_, options_.statistics, SOFT_RATE_LIMIT_DELAY_COUNT); + env_->SleepForMicroseconds(SlowdownAmount( + score, + options_.soft_rate_limit, + options_.hard_rate_limit) + ); + rate_limit_delay_millis += sw.ElapsedMicros(); + } allow_soft_rate_limit_delay = false; mutex_.Lock(); } else { diff --git a/include/leveldb/statistics.h b/include/leveldb/statistics.h index 6bd4a05fa..679236fee 100644 --- a/include/leveldb/statistics.h +++ b/include/leveldb/statistics.h @@ -113,8 +113,9 @@ enum Histograms { STALL_L0_SLOWDOWN_COUNT = 12, STALL_MEMTABLE_COMPACTION_COUNT = 13, STALL_L0_NUM_FILES_COUNT = 14, - RATE_LIMIT_DELAY_COUNT = 15, - HISTOGRAM_ENUM_MAX = 16 + HARD_RATE_LIMIT_DELAY_COUNT = 15, + SOFT_RATE_LIMIT_DELAY_COUNT = 16, + HISTOGRAM_ENUM_MAX = 17 }; const std::vector> HistogramsNameMap = { @@ -133,7 +134,8 @@ const std::vector> HistogramsNameMap = { { STALL_L0_SLOWDOWN_COUNT, "rocksdb.l0.slowdown.count"}, { STALL_MEMTABLE_COMPACTION_COUNT, "rocksdb.memtable.compaction.count"}, { STALL_L0_NUM_FILES_COUNT, "rocksdb.num.files.stall.count"}, - { RATE_LIMIT_DELAY_COUNT, "rocksdb.rate.limit.delay.count"} + { HARD_RATE_LIMIT_DELAY_COUNT, "rocksdb.hard.rate.limit.delay.count"}, + { SOFT_RATE_LIMIT_DELAY_COUNT, "rocksdb.soft.rate.limit.delay.count"} }; struct HistogramData {