From 0d537bb8a85e873c69ac2320b7811046a6bf5e32 Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Mon, 18 Dec 2023 17:49:25 +0100 Subject: [PATCH 1/2] Optimize RocksDB WAL file Signed-off-by: Fabio Di Fabio --- .../rocksdb/segmented/RocksDBColumnarKeyValueStorage.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBColumnarKeyValueStorage.java b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBColumnarKeyValueStorage.java index 952da71f0bc..c6157217e3d 100644 --- a/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBColumnarKeyValueStorage.java +++ b/plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBColumnarKeyValueStorage.java @@ -77,6 +77,11 @@ public abstract class RocksDBColumnarKeyValueStorage implements SegmentedKeyValu protected static final long ROCKSDB_BLOCKCACHE_SIZE_HIGH_SPEC = 1_073_741_824L; /** RocksDb memtable size when using the high spec option */ protected static final long ROCKSDB_MEMTABLE_SIZE_HIGH_SPEC = 1_073_741_824L; + /** Max total size of all WAL file, after which a flush is triggered */ + protected 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 */ + protected static final long EXPECTED_WAL_FILE_SIZE = 67_108_864L; + /** RocksDb number of log files to keep on disk */ private static final long NUMBER_OF_LOG_FILES_TO_KEEP = 7; /** RocksDb Time to roll a log file (1 day = 3600 * 24 seconds) */ @@ -237,6 +242,8 @@ private void setGlobalOptions(final RocksDBConfiguration configuration, final St options .setCreateIfMissing(true) .setMaxOpenFiles(configuration.getMaxOpenFiles()) + .setMaxTotalWalSize(WAL_MAX_TOTAL_SIZE) + .setRecycleLogFileNum(WAL_MAX_TOTAL_SIZE / EXPECTED_WAL_FILE_SIZE) .setStatistics(stats) .setCreateMissingColumnFamilies(true) .setLogFileTimeToRoll(TIME_TO_ROLL_LOG_FILE) From 90af6b08217e4fad716d00820df1b18a88ccbc92 Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Fri, 22 Dec 2023 16:35:47 +0100 Subject: [PATCH 2/2] Update CHANGELOG Signed-off-by: Fabio Di Fabio --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0275bd837a5..5acc7f19e0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - Set Ethereum Classic mainnet activation block for Spiral network upgrade [#6267](https://github.com/hyperledger/besu/pull/6267) - Add custom genesis file name to config overview if specified [#6297](https://github.com/hyperledger/besu/pull/6297) - Update Gradle plugins and replace unmaintained License Gradle Plugin with the actively maintained Gradle License Report [#6275](https://github.com/hyperledger/besu/pull/6275) +- Optimize RocksDB WAL files, allows for faster restart and a more linear disk space utilization [#6328](https://github.com/hyperledger/besu/pull/6328) ### Bug fixes