Skip to content

Commit

Permalink
Add MAX_BACKGROUND_JOBS config for RocksDB (#1694)
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhars-li authored Dec 9, 2023
1 parent 8ed3572 commit 082899d
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,20 @@ public class RocksDbOptionsHelper {
private static final String ROCKSDB_MAX_OPEN_FILES = "rocksdb.max.open.files";
private static final String ROCKSDB_MAX_FILE_OPENING_THREADS = "rocksdb.max.file.opening.threads";

private static final String ROCKSDB_MAX_BACKGROUND_JOBS = "rocksdb.max.background.jobs";

/**
* RocksDB default for {@link RocksDbOptionsHelper#ROCKSDB_COMPACTION_MAX_BACKGROUND_COMPACTIONS} is 1.
*/
private static final int DEFAULT_ROCKSDB_COMPACTION_MAX_BACKGROUND_COMPACTIONS = 4;

/**
* RocksDB default for {@link RocksDbOptionsHelper#ROCKSDB_MAX_BACKGROUND_JOBS} is 2
* Note: {@link RocksDbOptionsHelper#ROCKSDB_COMPACTION_MAX_BACKGROUND_COMPACTIONS} is deprecated and is decided by
* ROCKSDB_MAX_BACKGROUND_JOBS now.
*/
private static final int DEFAULT_ROCKSDB_MAX_BACKGROUND_JOBS = 4;


public static Options options(Config storeConfig, int numTasksForContainer, File storeDir, StorageEngineFactory.StoreMode storeMode) {
Options options = new Options();
Expand Down Expand Up @@ -174,6 +183,10 @@ private static void setCompactionOptions(Config storeConfig, Options options) {
options.setTargetFileSizeBase(storeConfig.getLong(ROCKSDB_COMPACTION_TARGET_FILE_SIZE_MULTIPLIER));
}

if (storeConfig.containsKey(ROCKSDB_MAX_BACKGROUND_JOBS)) {
options.setMaxBackgroundJobs(storeConfig.getInt(ROCKSDB_MAX_BACKGROUND_JOBS, DEFAULT_ROCKSDB_MAX_BACKGROUND_JOBS));
}

CompactionStyle compactionStyle = CompactionStyle.UNIVERSAL;
String compactionStyleInConfig = storeConfig.get(ROCKSDB_COMPACTION_STYLE, "universal");
switch (compactionStyleInConfig) {
Expand Down

0 comments on commit 082899d

Please sign in to comment.