From 3941c349501c516bdbfb06d3821bbbdb0d0d821c Mon Sep 17 00:00:00 2001 From: leipeng Date: Fri, 13 Jan 2023 11:47:26 -0800 Subject: [PATCH] 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 --- tools/db_bench_tool.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/db_bench_tool.cc b/tools/db_bench_tool.cc index 7182528b3..6aaf8c3b2 100644 --- a/tools/db_bench_tool.cc +++ b/tools/db_bench_tool.cc @@ -515,6 +515,8 @@ DEFINE_int32(max_background_compactions, " that can occur in parallel."); 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 " "into."); static const bool FLAGS_subcompactions_dummy __attribute__((__unused__)) = @@ -5656,6 +5658,8 @@ class Benchmark { // auto compactionOptions = CompactionOptions(); // db->CompactFiles(compactionOptions, file_names, 0); auto compactionOptions = CompactRangeOptions(); + compactionOptions.max_subcompactions = + static_cast(FLAGS_subcompactions); db->CompactRange(compactionOptions, nullptr, nullptr); } else { fprintf(stdout, @@ -8155,15 +8159,18 @@ class Benchmark { CompactRangeOptions cro; cro.bottommost_level_compaction = BottommostLevelCompaction::kForceOptimized; + cro.max_subcompactions = static_cast(FLAGS_subcompactions); db->CompactRange(cro, nullptr, nullptr); } void CompactAll() { + CompactRangeOptions cro; + cro.max_subcompactions = static_cast(FLAGS_subcompactions); if (db_.db != nullptr) { - db_.db->CompactRange(CompactRangeOptions(), nullptr, nullptr); + db_.db->CompactRange(cro, nullptr, nullptr); } for (const auto& db_with_cfh : multi_dbs_) { - db_with_cfh.db->CompactRange(CompactRangeOptions(), nullptr, nullptr); + db_with_cfh.db->CompactRange(cro, nullptr, nullptr); } }