From 1857576e031f1da57dfe153f3ac666aa13ee4a9c Mon Sep 17 00:00:00 2001 From: Pooja Malik Date: Wed, 18 Jul 2018 16:14:02 -0700 Subject: [PATCH] db_bench support for OPTIONS+bloom and nicer output for perf_context (#4153) Summary: Adding the string "PERF_CONTEXT:" before the perf_context stats are printed. Setting the filter policy if it's a block based table even when options are being loaded from the provided FLAGS_options_file. Pull Request resolved: https://github.com/facebook/rocksdb/pull/4153 Differential Revision: D8905517 Pulled By: poojam23 fbshipit-source-id: 5956ed7882d39ec8ae654d5dadeb88727a36f0dd --- tools/db_bench_tool.cc | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/tools/db_bench_tool.cc b/tools/db_bench_tool.cc index 6b8e814d4..95af4908b 100644 --- a/tools/db_bench_tool.cc +++ b/tools/db_bench_tool.cc @@ -3389,15 +3389,19 @@ void VerifyDBFromDB(std::string& truth_db_name) { options.compression_opts.max_dict_bytes = FLAGS_compression_max_dict_bytes; options.compression_opts.zstd_max_train_bytes = FLAGS_compression_zstd_max_train_bytes; - if (FLAGS_cache_size) { - // If this is a block based table, also need to set block_cache - if (options.table_factory->Name() == BlockBasedTableFactory::kName && - options.table_factory->GetOptions() != nullptr) { - BlockBasedTableOptions* table_options = - reinterpret_cast( - options.table_factory->GetOptions()); + // If this is a block based table, set some related options + if (options.table_factory->Name() == BlockBasedTableFactory::kName && + options.table_factory->GetOptions() != nullptr) { + BlockBasedTableOptions* table_options = + reinterpret_cast( + options.table_factory->GetOptions()); + if (FLAGS_cache_size) { table_options->block_cache = cache_; } + if (FLAGS_bloom_bits >= 0) { + table_options->filter_policy.reset(NewBloomFilterPolicy( + FLAGS_bloom_bits, FLAGS_use_block_based_filter)); + } } if (FLAGS_row_cache_size) { if (FLAGS_cache_numshardbits >= 1) { @@ -4174,7 +4178,8 @@ void VerifyDBFromDB(std::string& truth_db_name) { delete iter; thread->stats.AddBytes(bytes); if (FLAGS_perf_level > rocksdb::PerfLevel::kDisable) { - thread->stats.AddMessage(get_perf_context()->ToString()); + thread->stats.AddMessage( + std::string("PERF_CONTEXT:\n") + get_perf_context()->ToString()); } } @@ -4256,7 +4261,8 @@ void VerifyDBFromDB(std::string& truth_db_name) { thread->stats.AddMessage(msg); if (FLAGS_perf_level > rocksdb::PerfLevel::kDisable) { - thread->stats.AddMessage(get_perf_context()->ToString()); + thread->stats.AddMessage( + std::string("PERF_CONTEXT:\n") + get_perf_context()->ToString()); } } @@ -4334,7 +4340,8 @@ void VerifyDBFromDB(std::string& truth_db_name) { thread->stats.AddMessage(msg); if (FLAGS_perf_level > rocksdb::PerfLevel::kDisable) { - thread->stats.AddMessage(get_perf_context()->ToString()); + thread->stats.AddMessage( + std::string("PERF_CONTEXT:\n") + get_perf_context()->ToString()); } } @@ -4491,7 +4498,8 @@ void VerifyDBFromDB(std::string& truth_db_name) { thread->stats.AddBytes(bytes); thread->stats.AddMessage(msg); if (FLAGS_perf_level > rocksdb::PerfLevel::kDisable) { - thread->stats.AddMessage(get_perf_context()->ToString()); + thread->stats.AddMessage( + std::string("PERF_CONTEXT:\n") + get_perf_context()->ToString()); } } @@ -5242,7 +5250,8 @@ void VerifyDBFromDB(std::string& truth_db_name) { thread->stats.AddMessage(msg); if (FLAGS_perf_level > rocksdb::PerfLevel::kDisable) { - thread->stats.AddMessage(get_perf_context()->ToString()); + thread->stats.AddMessage( + std::string("PERF_CONTEXT:\n") + get_perf_context()->ToString()); } thread->stats.AddBytes(static_cast(inserter.GetBytesInserted())); } @@ -5404,7 +5413,8 @@ void VerifyDBFromDB(std::string& truth_db_name) { thread->stats.AddBytes(bytes); thread->stats.AddMessage(msg); if (FLAGS_perf_level > rocksdb::PerfLevel::kDisable) { - thread->stats.AddMessage(get_perf_context()->ToString()); + thread->stats.AddMessage( + std::string("PERF_CONTEXT:\n") + get_perf_context()->ToString()); } }