Skip to content

Commit

Permalink
ENG-3053: #101 pick better auto-defaults for max number of compactions
Browse files Browse the repository at this point in the history
Summary: Take into account number of cpus to decide max compactions in parallel.

Test Plan: Jenkins

Reviewers: mikhail, kannan

Reviewed By: kannan

Subscribers: ybase

Differential Revision: https://phabricator.dev.yugabyte.com/D4402
  • Loading branch information
bbaddepudi committed Mar 20, 2018
1 parent 28ca802 commit 956deb2
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/yb/docdb/docdb_rocksdb_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "yb/docdb/docdb_rocksdb_util.h"

#include <thread>
#include <memory>

#include "yb/common/transaction.h"
Expand All @@ -31,9 +32,9 @@ using namespace yb::size_literals; // NOLINT.

DEFINE_int32(rocksdb_max_background_flushes, 1, "Number threads to do background flushes.");
DEFINE_bool(rocksdb_disable_compactions, false, "Disable background compactions.");
DEFINE_int32(rocksdb_base_background_compactions, 2,
DEFINE_int32(rocksdb_base_background_compactions, -1,
"Number threads to do background compactions.");
DEFINE_int32(rocksdb_max_background_compactions, 2,
DEFINE_int32(rocksdb_max_background_compactions, -1,
"Increased number of threads to do background compactions (used when compactions need "
"to catch up.)");
DEFINE_int32(rocksdb_level0_file_num_compaction_trigger, 5,
Expand Down Expand Up @@ -413,6 +414,20 @@ void InitRocksDBOptions(
options->num_levels = 1;

if (compactions_enabled) {
if (FLAGS_rocksdb_max_background_compactions == -1) {
FLAGS_rocksdb_max_background_compactions = 4;
int num_cpus = std::thread::hardware_concurrency();
if (num_cpus <= 4) {
FLAGS_rocksdb_max_background_compactions = 1;
} else if (num_cpus <= 8) {
FLAGS_rocksdb_max_background_compactions = 2;
} else if (num_cpus <= 32) {
FLAGS_rocksdb_max_background_compactions = 3;
}
}
if (FLAGS_rocksdb_base_background_compactions == -1) {
FLAGS_rocksdb_base_background_compactions = FLAGS_rocksdb_max_background_compactions;
}
options->base_background_compactions = FLAGS_rocksdb_base_background_compactions;
options->max_background_compactions = FLAGS_rocksdb_max_background_compactions;
options->max_background_flushes = FLAGS_rocksdb_max_background_flushes;
Expand Down

0 comments on commit 956deb2

Please sign in to comment.