summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorsdong <siying.d@fb.com>2016-01-21 13:55:56 -0800
committersdong <siying.d@fb.com>2016-01-25 14:45:03 -0800
commitfb9811ee9bdb8582779ad713c750fc9ba0f42587 (patch)
treed084077d879c1de9130f75c042feedb653d70e77 /util
parentf7ef1a613276641af93f02f74f17cf66174d8126 (diff)
Add a perf context level that doesn't measure time for mutex operations
Summary: Timing mutex operations can impact scalability of the system. Add a new perf context level that can measure time counters except for mutex. Test Plan: Add a new unit test case to make sure it is not set. Reviewers: IslamAbdelRahman, rven, kradhakrishnan, yhchiang, anthony Reviewed By: anthony Subscribers: MarkCallaghan, leveldb, dhruba Differential Revision: https://reviews.facebook.net/D53199
Diffstat (limited to 'util')
-rw-r--r--util/instrumented_mutex.cc12
-rw-r--r--util/perf_context_imp.h8
-rw-r--r--util/perf_step_timer.h12
3 files changed, 16 insertions, 16 deletions
diff --git a/util/instrumented_mutex.cc b/util/instrumented_mutex.cc
index bfb989a1d..e5c6527be 100644
--- a/util/instrumented_mutex.cc
+++ b/util/instrumented_mutex.cc
@@ -9,8 +9,8 @@
namespace rocksdb {
void InstrumentedMutex::Lock() {
- PERF_CONDITIONAL_TIMER_GUARD(db_mutex_lock_nanos,
- stats_code_ == DB_MUTEX_WAIT_MICROS);
+ PERF_CONDITIONAL_TIMER_FOR_MUTEX_GUARD(db_mutex_lock_nanos,
+ stats_code_ == DB_MUTEX_WAIT_MICROS);
uint64_t wait_time_micros = 0;
if (env_ != nullptr && stats_ != nullptr) {
{
@@ -31,8 +31,8 @@ void InstrumentedMutex::LockInternal() {
}
void InstrumentedCondVar::Wait() {
- PERF_CONDITIONAL_TIMER_GUARD(db_condition_wait_nanos,
- stats_code_ == DB_MUTEX_WAIT_MICROS);
+ PERF_CONDITIONAL_TIMER_FOR_MUTEX_GUARD(db_condition_wait_nanos,
+ stats_code_ == DB_MUTEX_WAIT_MICROS);
uint64_t wait_time_micros = 0;
if (env_ != nullptr && stats_ != nullptr) {
{
@@ -53,8 +53,8 @@ void InstrumentedCondVar::WaitInternal() {
}
bool InstrumentedCondVar::TimedWait(uint64_t abs_time_us) {
- PERF_CONDITIONAL_TIMER_GUARD(db_condition_wait_nanos,
- stats_code_ == DB_MUTEX_WAIT_MICROS);
+ PERF_CONDITIONAL_TIMER_FOR_MUTEX_GUARD(db_condition_wait_nanos,
+ stats_code_ == DB_MUTEX_WAIT_MICROS);
uint64_t wait_time_micros = 0;
bool result = false;
if (env_ != nullptr && stats_ != nullptr) {
diff --git a/util/perf_context_imp.h b/util/perf_context_imp.h
index a5c4c39d9..d28b55179 100644
--- a/util/perf_context_imp.h
+++ b/util/perf_context_imp.h
@@ -33,10 +33,10 @@ namespace rocksdb {
PerfStepTimer perf_step_timer_ ## metric(&(perf_context.metric)); \
perf_step_timer_ ## metric.Start();
-#define PERF_CONDITIONAL_TIMER_GUARD(metric, condition) \
- PerfStepTimer perf_step_timer_##metric(&(perf_context.metric)); \
- if ((condition)) { \
- perf_step_timer_##metric.Start(); \
+#define PERF_CONDITIONAL_TIMER_FOR_MUTEX_GUARD(metric, condition) \
+ PerfStepTimer perf_step_timer_##metric(&(perf_context.metric), true); \
+ if ((condition)) { \
+ perf_step_timer_##metric.Start(); \
}
// Update metric with time elapsed since last START. start time is reset
diff --git a/util/perf_step_timer.h b/util/perf_step_timer.h
index 950258345..631cd317c 100644
--- a/util/perf_step_timer.h
+++ b/util/perf_step_timer.h
@@ -12,12 +12,12 @@ namespace rocksdb {
class PerfStepTimer {
public:
- PerfStepTimer(uint64_t* metric)
- : enabled_(perf_level >= PerfLevel::kEnableTime),
- env_(enabled_ ? Env::Default() : nullptr),
- start_(0),
- metric_(metric) {
- }
+ explicit PerfStepTimer(uint64_t* metric, bool for_mutex = false)
+ : enabled_(perf_level >= PerfLevel::kEnableTime ||
+ (!for_mutex && perf_level >= kEnableTimeExceptForMutex)),
+ env_(enabled_ ? Env::Default() : nullptr),
+ start_(0),
+ metric_(metric) {}
~PerfStepTimer() {
Stop();