From 376ce821818bd21b01d0c734b7453bdc865a9680 Mon Sep 17 00:00:00 2001 From: ahamlat Date: Tue, 22 Nov 2022 14:00:34 +0100 Subject: [PATCH] Enable RocksDB bloomFilters (#4682) * Enable full (non block) bloomFilters with 10 bits per key Signed-off-by: Ameziane H * Delete unused constant Signed-off-by: Ameziane H * Add ChangeLog Signed-off-by: Ameziane H * Set RocksDB format version to 5 Signed-off-by: Ameziane H Signed-off-by: Ameziane H Signed-off-by: ahamlat --- CHANGELOG.md | 1 + .../segmented/RocksDBColumnarKeyValueStorage.java | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42252c1e8c..6ea127394d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - Upgrade OpenTelemetry to version 1.19.0 [#3675](https://github.com/hyperledger/besu/pull/3675) - Implement Eth/67 sub-protocol [#4596](https://github.com/hyperledger/besu/issues/4596) - Backward sync log UX improvements [#4655](https://github.com/hyperledger/besu/pull/4655) +- Enable RocksDB Bloom filters to improve read performance [#4682](https://github.com/hyperledger/besu/pull/4682) - Backward sync: use retry switching peer when fetching data from peers [#4656](https://github.com/hyperledger/besu/pull/4656) - Shanghai implementation of EIP-3651 Warm coinbase [#4620](https://github.com/hyperledger/besu/pull/4620) - Shanghai implementation of EIP-3855 Push0 [#4660](https://github.com/hyperledger/besu/pull/4660) 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 564a9be9eb..d4811f6278 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 @@ -45,6 +45,7 @@ import com.google.common.collect.ImmutableMap; import org.apache.commons.lang3.tuple.Pair; import org.apache.tuweni.bytes.Bytes; import org.rocksdb.BlockBasedTableConfig; +import org.rocksdb.BloomFilter; import org.rocksdb.ColumnFamilyDescriptor; import org.rocksdb.ColumnFamilyHandle; import org.rocksdb.ColumnFamilyOptions; @@ -174,10 +175,11 @@ public class RocksDBColumnarKeyValueStorage private BlockBasedTableConfig createBlockBasedTableConfigHighSpec() { final LRUCache cache = new LRUCache(ROCKSDB_BLOCKCACHE_SIZE_HIGH_SPEC); return new BlockBasedTableConfig() - .setBlockCache(cache) .setFormatVersion(ROCKSDB_FORMAT_VERSION) - .setOptimizeFiltersForMemory(true) - .setCacheIndexAndFilterBlocks(true) + .setBlockCache(cache) + .setFilterPolicy(new BloomFilter(10, false)) + .setPartitionFilters(true) + .setCacheIndexAndFilterBlocks(false) .setBlockSize(ROCKSDB_BLOCK_SIZE); } @@ -185,10 +187,11 @@ public class RocksDBColumnarKeyValueStorage final RocksDBConfiguration config) { final LRUCache cache = new LRUCache(config.getCacheCapacity()); return new BlockBasedTableConfig() - .setBlockCache(cache) .setFormatVersion(ROCKSDB_FORMAT_VERSION) - .setOptimizeFiltersForMemory(true) - .setCacheIndexAndFilterBlocks(true) + .setBlockCache(cache) + .setFilterPolicy(new BloomFilter(10, false)) + .setPartitionFilters(true) + .setCacheIndexAndFilterBlocks(false) .setBlockSize(ROCKSDB_BLOCK_SIZE); }