Skip to content

Commit

Permalink
fix compiler errors with -DNPERF_CONTEXT (facebook#6642)
Browse files Browse the repository at this point in the history
Summary:
as titled
Pull Request resolved: facebook#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
  • Loading branch information
ajkr authored and facebook-github-bot committed Apr 3, 2020
1 parent 259b6ec commit e60ea7f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions monitoring/instrumented_mutex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

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

void InstrumentedMutex::Lock() {
Expand Down
13 changes: 10 additions & 3 deletions monitoring/perf_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ PerfContext::~PerfContext() {
}

PerfContext::PerfContext(const PerfContext& other) {
#ifndef NPERF_CONTEXT
#ifdef NPERF_CONTEXT
(void)other;
#else
user_key_comparison_count = other.user_key_comparison_count;
block_cache_hit_count = other.block_cache_hit_count;
block_read_count = other.block_read_count;
Expand Down Expand Up @@ -133,7 +135,9 @@ PerfContext::PerfContext(const PerfContext& other) {
}

PerfContext::PerfContext(PerfContext&& other) noexcept {
#ifndef NPERF_CONTEXT
#ifdef NPERF_CONTEXT
(void)other;
#else
user_key_comparison_count = other.user_key_comparison_count;
block_cache_hit_count = other.block_cache_hit_count;
block_read_count = other.block_read_count;
Expand Down Expand Up @@ -230,7 +234,9 @@ PerfContext::PerfContext(PerfContext&& other) noexcept {
// TODO(Zhongyi): reduce code duplication between copy constructor and
// assignment operator
PerfContext& PerfContext::operator=(const PerfContext& other) {
#ifndef NPERF_CONTEXT
#ifdef NPERF_CONTEXT
(void)other;
#else
user_key_comparison_count = other.user_key_comparison_count;
block_cache_hit_count = other.block_cache_hit_count;
block_read_count = other.block_read_count;
Expand Down Expand Up @@ -443,6 +449,7 @@ void PerfContextByLevel::Reset() {

std::string PerfContext::ToString(bool exclude_zero_counters) const {
#ifdef NPERF_CONTEXT
(void)exclude_zero_counters;
return "";
#else
std::ostringstream ss;
Expand Down

0 comments on commit e60ea7f

Please sign in to comment.