fix compiler errors with -DNPERF_CONTEXT (#6642)

Summary:
as titled
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6642

Test Plan:
```
$ EXTRA_CXXFLAGS="-DNPERF_CONTEXT" DEBUG_LEVEL=0 make -j48 db_bench
```

Reviewed By: riversand963

Differential Revision: D20842313

Pulled By: ajkr

fbshipit-source-id: a830cad312ca681591f06749242279503b101df2
main
Andrew Kryczka 5 years ago committed by Facebook GitHub Bot
parent 259b6ec8da
commit e60ea7fe57
  1. 2
      monitoring/instrumented_mutex.cc
  2. 13
      monitoring/perf_context.cc

@ -10,6 +10,7 @@
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
namespace { namespace {
#ifndef NPERF_CONTEXT
Statistics* stats_for_report(Env* env, Statistics* stats) { Statistics* stats_for_report(Env* env, Statistics* stats) {
if (env != nullptr && stats != nullptr && if (env != nullptr && stats != nullptr &&
stats->get_stats_level() > kExceptTimeForMutex) { stats->get_stats_level() > kExceptTimeForMutex) {
@ -18,6 +19,7 @@ Statistics* stats_for_report(Env* env, Statistics* stats) {
return nullptr; return nullptr;
} }
} }
#endif // NPERF_CONTEXT
} // namespace } // namespace
void InstrumentedMutex::Lock() { void InstrumentedMutex::Lock() {

@ -38,7 +38,9 @@ PerfContext::~PerfContext() {
} }
PerfContext::PerfContext(const PerfContext& other) { PerfContext::PerfContext(const PerfContext& other) {
#ifndef NPERF_CONTEXT #ifdef NPERF_CONTEXT
(void)other;
#else
user_key_comparison_count = other.user_key_comparison_count; user_key_comparison_count = other.user_key_comparison_count;
block_cache_hit_count = other.block_cache_hit_count; block_cache_hit_count = other.block_cache_hit_count;
block_read_count = other.block_read_count; block_read_count = other.block_read_count;
@ -133,7 +135,9 @@ PerfContext::PerfContext(const PerfContext& other) {
} }
PerfContext::PerfContext(PerfContext&& other) noexcept { PerfContext::PerfContext(PerfContext&& other) noexcept {
#ifndef NPERF_CONTEXT #ifdef NPERF_CONTEXT
(void)other;
#else
user_key_comparison_count = other.user_key_comparison_count; user_key_comparison_count = other.user_key_comparison_count;
block_cache_hit_count = other.block_cache_hit_count; block_cache_hit_count = other.block_cache_hit_count;
block_read_count = other.block_read_count; block_read_count = other.block_read_count;
@ -230,7 +234,9 @@ PerfContext::PerfContext(PerfContext&& other) noexcept {
// TODO(Zhongyi): reduce code duplication between copy constructor and // TODO(Zhongyi): reduce code duplication between copy constructor and
// assignment operator // assignment operator
PerfContext& PerfContext::operator=(const PerfContext& other) { PerfContext& PerfContext::operator=(const PerfContext& other) {
#ifndef NPERF_CONTEXT #ifdef NPERF_CONTEXT
(void)other;
#else
user_key_comparison_count = other.user_key_comparison_count; user_key_comparison_count = other.user_key_comparison_count;
block_cache_hit_count = other.block_cache_hit_count; block_cache_hit_count = other.block_cache_hit_count;
block_read_count = other.block_read_count; block_read_count = other.block_read_count;
@ -443,6 +449,7 @@ void PerfContextByLevel::Reset() {
std::string PerfContext::ToString(bool exclude_zero_counters) const { std::string PerfContext::ToString(bool exclude_zero_counters) const {
#ifdef NPERF_CONTEXT #ifdef NPERF_CONTEXT
(void)exclude_zero_counters;
return ""; return "";
#else #else
std::ostringstream ss; std::ostringstream ss;

Loading…
Cancel
Save