Skip to content

Commit

Permalink
OSS samza-li merge (apache#18)
Browse files Browse the repository at this point in the history
* Add MAX_BACKGROUND_JOBS config for RocksDB (apache#1694)

Co-authored-by: Shekhar Sharma <[email protected]>
  • Loading branch information
shekhars-li and shekhars-li authored Dec 11, 2023
1 parent 3b501d4 commit bff5f7c
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 bff5f7c

Please sign in to comment.