Ensure Correct Behavior of StatsLevel kExceptDetailedTimers and kExceptTimeForMutex (#1308)

* Fix StatsLevel so that kExceptTimeForMutex leaves compression stats enabled and kExceptDetailedTimers disables mutex lock stats. Also change default stats level to kExceptDetailedTimers (disabling both compression and mutex timing).

* Changed order of StatsLevel enum to simplify logic for determining what stats to record.
main
John Alexander 8 years ago committed by Islam AbdelRahman
parent e14fbaae26
commit 4fd08f4b8b
  1. 2
      db/db_test.cc
  2. 8
      include/rocksdb/statistics.h
  3. 2
      util/instrumented_mutex.cc

@ -4718,7 +4718,7 @@ TEST_F(DBTest, CompressionStatsTest) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.compression = type; options.compression = type;
options.statistics = rocksdb::CreateDBStatistics(); options.statistics = rocksdb::CreateDBStatistics();
options.statistics->stats_level_ = StatsLevel::kAll; options.statistics->stats_level_ = StatsLevel::kExceptTimeForMutex;
DestroyAndReopen(options); DestroyAndReopen(options);
int kNumKeysWritten = 100000; int kNumKeysWritten = 100000;

@ -393,12 +393,12 @@ struct HistogramData {
}; };
enum StatsLevel { enum StatsLevel {
// Collect all stats except time inside mutex lock AND time spent on
// compression.
kExceptDetailedTimers,
// Collect all stats except the counters requiring to get time inside the // Collect all stats except the counters requiring to get time inside the
// mutex lock. // mutex lock.
kExceptTimeForMutex, kExceptTimeForMutex,
// Collect all stats expect time inside mutex lock AND time spent on
// compression
kExceptDetailedTimers,
// Collect all stats, including measuring duration of mutex operations. // Collect all stats, including measuring duration of mutex operations.
// If getting time is expensive on the platform to run, it can // If getting time is expensive on the platform to run, it can
// reduce scalability to more threads, especially for writes. // reduce scalability to more threads, especially for writes.
@ -429,7 +429,7 @@ class Statistics {
return type < HISTOGRAM_ENUM_MAX; return type < HISTOGRAM_ENUM_MAX;
} }
StatsLevel stats_level_ = kExceptTimeForMutex; StatsLevel stats_level_ = kExceptDetailedTimers;
}; };
// Create a concrete DBStatistics object // Create a concrete DBStatistics object

@ -11,7 +11,7 @@ namespace rocksdb {
namespace { namespace {
bool ShouldReportToStats(Env* env, Statistics* stats) { bool ShouldReportToStats(Env* env, Statistics* stats) {
return env != nullptr && stats != nullptr && return env != nullptr && stats != nullptr &&
stats->stats_level_ != kExceptTimeForMutex; stats->stats_level_ > kExceptTimeForMutex;
} }
} // namespace } // namespace

Loading…
Cancel
Save