From dd759537d04d9770eac1a2c654a53334c5fde00b Mon Sep 17 00:00:00 2001 From: Yanqin Jin Date: Fri, 22 Jul 2022 09:19:25 -0700 Subject: [PATCH] Print perf context for all benchmarks if enabled (#10396) Summary: If user runs `db_bench` with `-perf_level=2` or higher, db_bench should print perf context after each of all benchmarks. Or make `-perf_level` a per-benchmark switch. Pull Request resolved: https://github.com/facebook/rocksdb/pull/10396 Test Plan: ./db_bench -benchmarks=fillseq,readseq -perf_level=2 Reviewed By: ajkr Differential Revision: D38016324 Pulled By: riversand963 fbshipit-source-id: d83ea4abc34d40ffea394ca6abf0814bc5c0a2e0 --- tools/db_bench_tool.cc | 46 ++++++++---------------------------------- 1 file changed, 8 insertions(+), 38 deletions(-) diff --git a/tools/db_bench_tool.cc b/tools/db_bench_tool.cc index f0b5eb493..68488cb40 100644 --- a/tools/db_bench_tool.cc +++ b/tools/db_bench_tool.cc @@ -758,6 +758,9 @@ DEFINE_bool(show_table_properties, false, DEFINE_string(db, "", "Use the db with the following name."); +DEFINE_bool(progress_reports, true, + "If true, db_bench will report number of finished operations."); + // Read cache flags DEFINE_string(read_cache_path, "", @@ -2252,7 +2255,7 @@ class Stats { } done_ += num_ops; - if (done_ >= next_report_) { + if (done_ >= next_report_ && FLAGS_progress_reports) { if (!FLAGS_stats_interval) { if (next_report_ < 1000) next_report_ += 100; else if (next_report_ < 5000) next_report_ += 500; @@ -3814,6 +3817,10 @@ class Benchmark { perf_context.EnablePerLevelPerfContext(); thread->stats.Start(thread->tid); (arg->bm->*(arg->method))(thread); + if (FLAGS_perf_level > ROCKSDB_NAMESPACE::PerfLevel::kDisable) { + thread->stats.AddMessage(std::string("PERF_CONTEXT:\n") + + get_perf_context()->ToString()); + } thread->stats.Stop(); { @@ -5743,10 +5750,6 @@ class Benchmark { delete iter; thread->stats.AddBytes(bytes); - if (FLAGS_perf_level > ROCKSDB_NAMESPACE::PerfLevel::kDisable) { - thread->stats.AddMessage(std::string("PERF_CONTEXT:\n") + - get_perf_context()->ToString()); - } } void ReadToRowCache(ThreadState* thread) { @@ -5800,11 +5803,6 @@ class Benchmark { thread->stats.AddBytes(bytes); thread->stats.AddMessage(msg); - - if (FLAGS_perf_level > ROCKSDB_NAMESPACE::PerfLevel::kDisable) { - thread->stats.AddMessage(std::string("PERF_CONTEXT:\n") + - get_perf_context()->ToString()); - } } void ReadReverse(ThreadState* thread) { @@ -5896,11 +5894,6 @@ class Benchmark { found, read, nonexist); thread->stats.AddMessage(msg); - - if (FLAGS_perf_level > ROCKSDB_NAMESPACE::PerfLevel::kDisable) { - thread->stats.AddMessage(std::string("PERF_CONTEXT:\n") + - get_perf_context()->ToString()); - } } int64_t GetRandomKey(Random64* rand) { @@ -6036,11 +6029,6 @@ class Benchmark { thread->stats.AddBytes(bytes); thread->stats.AddMessage(msg); - - if (FLAGS_perf_level > ROCKSDB_NAMESPACE::PerfLevel::kDisable) { - thread->stats.AddMessage(std::string("PERF_CONTEXT:\n") + - get_perf_context()->ToString()); - } } // Calls MultiGet over a list of keys from a random distribution. @@ -6602,11 +6590,6 @@ class Benchmark { thread->stats.AddBytes(bytes); thread->stats.AddMessage(msg); - - if (FLAGS_perf_level > ROCKSDB_NAMESPACE::PerfLevel::kDisable) { - thread->stats.AddMessage(std::string("PERF_CONTEXT:\n") + - get_perf_context()->ToString()); - } } void IteratorCreation(ThreadState* thread) { @@ -6756,10 +6739,6 @@ class Benchmark { found, read); thread->stats.AddBytes(bytes); thread->stats.AddMessage(msg); - if (FLAGS_perf_level > ROCKSDB_NAMESPACE::PerfLevel::kDisable) { - thread->stats.AddMessage(std::string("PERF_CONTEXT:\n") + - get_perf_context()->ToString()); - } } void SeekRandomWhileWriting(ThreadState* thread) { @@ -7782,11 +7761,6 @@ class Benchmark { snprintf(msg, sizeof(msg), "( batches:%" PRIu64 " )", transactions_done); } thread->stats.AddMessage(msg); - - if (FLAGS_perf_level > ROCKSDB_NAMESPACE::PerfLevel::kDisable) { - thread->stats.AddMessage(std::string("PERF_CONTEXT:\n") + - get_perf_context()->ToString()); - } thread->stats.AddBytes(static_cast(inserter.GetBytesInserted())); } @@ -7965,10 +7939,6 @@ class Benchmark { read); thread->stats.AddBytes(bytes); thread->stats.AddMessage(msg); - if (FLAGS_perf_level > ROCKSDB_NAMESPACE::PerfLevel::kDisable) { - thread->stats.AddMessage(std::string("PERF_CONTEXT:\n") + - get_perf_context()->ToString()); - } } void TimeSeriesWrite(ThreadState* thread) {