Fixed the db_bench MergeRandom only access CF_default (#4155)

Summary:
When running the tracing and analyzing, I found that MergeRandom benchmark in db_bench only access the default column family even the -num_column_families is specified > 1.

changes: Using the db_with_cfh as DB to randomly select the column family to execute the Merge operation if -num_column_families is specified > 1.

Tested with make asan_check and verified in tracing
Pull Request resolved: https://github.com/facebook/rocksdb/pull/4155

Differential Revision: D8907888

Pulled By: zhichao-cao

fbshipit-source-id: 2b4bc8fe0e99c8f262f5be6b986c7025d62cf850
main
Zhichao Cao 6 years ago committed by Facebook Github Bot
parent a5e851e113
commit 6811fb0658
  1. 18
      tools/db_bench_tool.cc

@ -5061,17 +5061,27 @@ void VerifyDBFromDB(std::string& truth_db_name) {
// The number of iterations is the larger of read_ or write_
Duration duration(FLAGS_duration, readwrites_);
while (!duration.Done(1)) {
DB* db = SelectDB(thread);
GenerateKeyFromInt(thread->rand.Next() % merge_keys_, merge_keys_, &key);
DBWithColumnFamilies* db_with_cfh = SelectDBWithCfh(thread);
int64_t key_rand = thread->rand.Next() % merge_keys_;
GenerateKeyFromInt(key_rand, merge_keys_, &key);
Status s = db->Merge(write_options_, key, gen.Generate(value_size_));
Status s;
if (FLAGS_num_column_families > 1) {
s = db_with_cfh->db->Merge(write_options_,
db_with_cfh->GetCfh(key_rand), key,
gen.Generate(value_size_));
} else {
s = db_with_cfh->db->Merge(write_options_,
db_with_cfh->db->DefaultColumnFamily(), key,
gen.Generate(value_size_));
}
if (!s.ok()) {
fprintf(stderr, "merge error: %s\n", s.ToString().c_str());
exit(1);
}
bytes += key.size() + value_size_;
thread->stats.FinishedOps(nullptr, db, 1, kMerge);
thread->stats.FinishedOps(nullptr, db_with_cfh->db, 1, kMerge);
}
// Print some statistics

Loading…
Cancel
Save