Skip to content

Commit 2f19228

Browse files
authored
Optimize RocksDB WAL file (#6328)
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
1 parent 7b27d3b commit 2f19228

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- Set Ethereum Classic mainnet activation block for Spiral network upgrade [#6267](https://github.com/hyperledger/besu/pull/6267)
1414
- Add custom genesis file name to config overview if specified [#6297](https://github.com/hyperledger/besu/pull/6297)
1515
- Update Gradle plugins and replace unmaintained License Gradle Plugin with the actively maintained Gradle License Report [#6275](https://github.com/hyperledger/besu/pull/6275)
16+
- Optimize RocksDB WAL files, allows for faster restart and a more linear disk space utilization [#6328](https://github.com/hyperledger/besu/pull/6328)
1617

1718
### Bug fixes
1819

plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBColumnarKeyValueStorage.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ public abstract class RocksDBColumnarKeyValueStorage implements SegmentedKeyValu
7777
protected static final long ROCKSDB_BLOCKCACHE_SIZE_HIGH_SPEC = 1_073_741_824L;
7878
/** RocksDb memtable size when using the high spec option */
7979
protected static final long ROCKSDB_MEMTABLE_SIZE_HIGH_SPEC = 1_073_741_824L;
80+
/** Max total size of all WAL file, after which a flush is triggered */
81+
protected static final long WAL_MAX_TOTAL_SIZE = 1_073_741_824L;
82+
/** Expected size of a single WAL file, to determine how many WAL files to keep around */
83+
protected static final long EXPECTED_WAL_FILE_SIZE = 67_108_864L;
84+
8085
/** RocksDb number of log files to keep on disk */
8186
private static final long NUMBER_OF_LOG_FILES_TO_KEEP = 7;
8287
/** RocksDb Time to roll a log file (1 day = 3600 * 24 seconds) */
@@ -237,6 +242,8 @@ private void setGlobalOptions(final RocksDBConfiguration configuration, final St
237242
options
238243
.setCreateIfMissing(true)
239244
.setMaxOpenFiles(configuration.getMaxOpenFiles())
245+
.setMaxTotalWalSize(WAL_MAX_TOTAL_SIZE)
246+
.setRecycleLogFileNum(WAL_MAX_TOTAL_SIZE / EXPECTED_WAL_FILE_SIZE)
240247
.setStatistics(stats)
241248
.setCreateMissingColumnFamilies(true)
242249
.setLogFileTimeToRoll(TIME_TO_ROLL_LOG_FILE)

0 commit comments

Comments
 (0)