Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rocksdb performance improvements #9080

Merged
merged 6 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class KvStoreConfiguration {

public static final int DEFAULT_MAX_BACKGROUND_JOBS = 6;
public static final int DEFAULT_BACKGROUND_THREAD_COUNT = 6;
public static final long DEFAULT_CACHE_CAPACITY = 8 << 20; // 8MB
public static final long DEFAULT_CACHE_CAPACITY = 134217728; // 128MB
gfukushima marked this conversation as resolved.
Show resolved Hide resolved
public static final long DEFAULT_WRITE_BUFFER_CAPACITY = 128 << 20;
private static final boolean DEFAULT_OPTIMISE_FOR_SMALL_DB = false;

Expand All @@ -61,6 +61,12 @@ public class KvStoreConfiguration {
/** RocksDb Time to roll a log file (1 day = 3600 * 24 seconds) */
public static final long TIME_TO_ROLL_LOG_FILE = 86_400L;

/** Max total size of all WAL file, after which a flush is triggered */
public static final long WAL_MAX_TOTAL_SIZE = 1_073_741_824L;

/** Expected size of a single WAL file, to determine how many WAL files to keep around */
public static final long EXPECTED_WAL_FILE_SIZE = 67_108_864L;

public static final long ROCKSDB_BLOCK_SIZE = 32_768;

/* --------------- Safe to Change Properties ------------ */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
package tech.pegasys.teku.storage.server.rocksdb;

import static com.google.common.base.Preconditions.checkArgument;
import static tech.pegasys.teku.storage.server.kvstore.KvStoreConfiguration.EXPECTED_WAL_FILE_SIZE;
import static tech.pegasys.teku.storage.server.kvstore.KvStoreConfiguration.NUMBER_OF_LOG_FILES_TO_KEEP;
import static tech.pegasys.teku.storage.server.kvstore.KvStoreConfiguration.ROCKSDB_BLOCK_SIZE;
import static tech.pegasys.teku.storage.server.kvstore.KvStoreConfiguration.TIME_TO_ROLL_LOG_FILE;
import static tech.pegasys.teku.storage.server.kvstore.KvStoreConfiguration.WAL_MAX_TOTAL_SIZE;

import com.google.common.collect.ImmutableMap;
import java.util.ArrayList;
Expand Down Expand Up @@ -151,7 +153,10 @@ private static DBOptions createDBOptions(
.setLogFileTimeToRoll(TIME_TO_ROLL_LOG_FILE)
.setKeepLogFileNum(NUMBER_OF_LOG_FILES_TO_KEEP)
.setEnv(Env.getDefault().setBackgroundThreads(configuration.getBackgroundThreadCount()))
.setStatistics(stats);
.setStatistics(stats)
.setMaxTotalWalSize(WAL_MAX_TOTAL_SIZE)
.setRecycleLogFileNum(WAL_MAX_TOTAL_SIZE / EXPECTED_WAL_FILE_SIZE);
;

// Java docs suggests this if db is under 1GB, nearly impossible atm
if (configuration.optimizeForSmallDb()) {
Expand All @@ -165,7 +170,7 @@ private static ColumnFamilyOptions createColumnFamilyOptions(
final KvStoreConfiguration configuration, final Cache cache) {
return new ColumnFamilyOptions()
.setCompressionType(configuration.getCompressionType())
.setBottommostCompressionType(configuration.getBottomMostCompressionType())
gfukushima marked this conversation as resolved.
Show resolved Hide resolved
.setLevelCompactionDynamicLevelBytes(true)
.setTtl(0)
.setTableFormatConfig(createBlockBasedTableConfig(cache));
}
Expand All @@ -189,7 +194,7 @@ private static BlockBasedTableConfig createBlockBasedTableConfig(final Cache cac
.setBlockCache(cache)
.setFilterPolicy(new BloomFilter(10, false))
.setPartitionFilters(true)
.setCacheIndexAndFilterBlocks(true)
.setCacheIndexAndFilterBlocks(false)
.setBlockSize(ROCKSDB_BLOCK_SIZE);
}
}