Skip to content

Commit

Permalink
another day another tweak on rocks config
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Fukushima <[email protected]>
  • Loading branch information
gfukushima committed Feb 3, 2025
1 parent 2e47a5c commit dbae7f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ 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;

public static final long ROCKSDB_BLOCK_SIZE = 16_384;
/** 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 @@ -150,7 +152,9 @@ 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 +169,6 @@ private static ColumnFamilyOptions createColumnFamilyOptions(
return new ColumnFamilyOptions()
.setLevelCompactionDynamicLevelBytes(true)
.setCompressionType(configuration.getCompressionType())
.setBottommostCompressionType(configuration.getBottomMostCompressionType())
.setTtl(0)
.setTableFormatConfig(createBlockBasedTableConfig(cache));
}
Expand All @@ -189,8 +192,7 @@ private static BlockBasedTableConfig createBlockBasedTableConfig(final Cache cac
.setBlockCache(cache)
.setFilterPolicy(new BloomFilter(10, false))
.setPartitionFilters(true)
.setCacheIndexAndFilterBlocks(true)
.setPinL0FilterAndIndexBlocksInCache(true)
.setCacheIndexAndFilterBlocks(false)
.setBlockSize(ROCKSDB_BLOCK_SIZE);
}
}

0 comments on commit dbae7f4

Please sign in to comment.