option to print malloc stats at the end of db_bench (#4582)

Summary:
Option to print malloc stats to stdout at the end of db_bench. This is different from `--dump_malloc_stats`, which periodically print the same information to LOG file.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/4582

Differential Revision: D10520814

Pulled By: yiwu-arbug

fbshipit-source-id: beff5e514e414079d31092b630813f82939ffe5c
main
Yi Wu 6 years ago committed by Facebook Github Bot
parent 43dbd4411e
commit 0415244bfa
  1. 13
      tools/db_bench_tool.cc

@ -33,10 +33,12 @@
#include <unordered_map>
#include "db/db_impl.h"
#include "db/malloc_stats.h"
#include "db/version_set.h"
#include "hdfs/env_hdfs.h"
#include "monitoring/histogram.h"
#include "monitoring/statistics.h"
#include "options/cf_options.h"
#include "port/port.h"
#include "port/stack_trace.h"
#include "rocksdb/cache.h"
@ -45,7 +47,6 @@
#include "rocksdb/filter_policy.h"
#include "rocksdb/memtablerep.h"
#include "rocksdb/options.h"
#include "options/cf_options.h"
#include "rocksdb/perf_context.h"
#include "rocksdb/persistent_cache.h"
#include "rocksdb/rate_limiter.h"
@ -1038,6 +1039,9 @@ DEFINE_bool(dump_malloc_stats, true, "Dump malloc stats in LOG ");
DEFINE_uint64(stats_dump_period_sec, rocksdb::Options().stats_dump_period_sec,
"Gap between printing stats to log in seconds");
DEFINE_bool(print_malloc_stats, false,
"Print malloc stats to stdout after benchmarks finish.");
enum RepFactory {
kSkipList,
kPrefixHash,
@ -5804,6 +5808,13 @@ int db_bench_tool(int argc, char** argv) {
rocksdb::Benchmark benchmark;
benchmark.Run();
if (FLAGS_print_malloc_stats) {
std::string stats_string;
rocksdb::DumpMallocStats(&stats_string);
fprintf(stdout, "Malloc stats:\n%s\n", stats_string.c_str());
}
return 0;
}
} // namespace rocksdb

Loading…
Cancel
Save