db_bench: let -benchmark=compact respect -subcompactions (#11077)

Summary:
When running `-benchmarks=compact`, `-subcompactions` does not take effect.

`-subcompactions` option comment says it is for L0-L1 compactions, it is natural to extend it to CompactionRangeOptions.max_subcompactions.

This PR set CompactionRangeOptions.max_subcompactions = FLAGS_subcompactions

Pull Request resolved: https://github.com/facebook/rocksdb/pull/11077

Reviewed By: akankshamahajan15

Differential Revision: D42506251

Pulled By: ajkr

fbshipit-source-id: f77c9a99d32ff7af59f3c452c9e16aaeb0360304
oxigraph-8.1.1
leipeng 2 years ago committed by Facebook GitHub Bot
parent 1cfe3528a2
commit 3941c34950
  1. 11
      tools/db_bench_tool.cc

@ -515,6 +515,8 @@ DEFINE_int32(max_background_compactions,
" that can occur in parallel."); " that can occur in parallel.");
DEFINE_uint64(subcompactions, 1, DEFINE_uint64(subcompactions, 1,
"For CompactRange, set max_subcompactions for each compaction "
"job in this CompactRange, for auto compactions, this is "
"Maximum number of subcompactions to divide L0-L1 compactions " "Maximum number of subcompactions to divide L0-L1 compactions "
"into."); "into.");
static const bool FLAGS_subcompactions_dummy __attribute__((__unused__)) = static const bool FLAGS_subcompactions_dummy __attribute__((__unused__)) =
@ -5656,6 +5658,8 @@ class Benchmark {
// auto compactionOptions = CompactionOptions(); // auto compactionOptions = CompactionOptions();
// db->CompactFiles(compactionOptions, file_names, 0); // db->CompactFiles(compactionOptions, file_names, 0);
auto compactionOptions = CompactRangeOptions(); auto compactionOptions = CompactRangeOptions();
compactionOptions.max_subcompactions =
static_cast<uint32_t>(FLAGS_subcompactions);
db->CompactRange(compactionOptions, nullptr, nullptr); db->CompactRange(compactionOptions, nullptr, nullptr);
} else { } else {
fprintf(stdout, fprintf(stdout,
@ -8155,15 +8159,18 @@ class Benchmark {
CompactRangeOptions cro; CompactRangeOptions cro;
cro.bottommost_level_compaction = cro.bottommost_level_compaction =
BottommostLevelCompaction::kForceOptimized; BottommostLevelCompaction::kForceOptimized;
cro.max_subcompactions = static_cast<uint32_t>(FLAGS_subcompactions);
db->CompactRange(cro, nullptr, nullptr); db->CompactRange(cro, nullptr, nullptr);
} }
void CompactAll() { void CompactAll() {
CompactRangeOptions cro;
cro.max_subcompactions = static_cast<uint32_t>(FLAGS_subcompactions);
if (db_.db != nullptr) { if (db_.db != nullptr) {
db_.db->CompactRange(CompactRangeOptions(), nullptr, nullptr); db_.db->CompactRange(cro, nullptr, nullptr);
} }
for (const auto& db_with_cfh : multi_dbs_) { for (const auto& db_with_cfh : multi_dbs_) {
db_with_cfh.db->CompactRange(CompactRangeOptions(), nullptr, nullptr); db_with_cfh.db->CompactRange(cro, nullptr, nullptr);
} }
} }

Loading…
Cancel
Save