From 2010be987352fccde1245d6e99bd711c330d06e0 Mon Sep 17 00:00:00 2001 From: renancloudwalk <53792026+renancloudwalk@users.noreply.github.com> Date: Mon, 1 Apr 2024 16:42:42 -0300 Subject: [PATCH] Rocksdb fine tunning (#496) * chore: increase paralellism for flush and compression * using block based options * chore: use block based table --- src/eth/storage/hybrid/rocks_db.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/eth/storage/hybrid/rocks_db.rs b/src/eth/storage/hybrid/rocks_db.rs index 202c09946..74db36465 100644 --- a/src/eth/storage/hybrid/rocks_db.rs +++ b/src/eth/storage/hybrid/rocks_db.rs @@ -1,6 +1,7 @@ use std::marker::PhantomData; use anyhow::Result; +use rocksdb::BlockBasedOptions; use rocksdb::DBIteratorWithThreadMode; use rocksdb::IteratorMode; use rocksdb::Options; @@ -23,6 +24,7 @@ pub struct RocksDb { impl Deserialize<'de> + std::hash::Hash + Eq, V: Serialize + for<'de> Deserialize<'de> + Clone> RocksDb { pub fn new(db_path: &str, config: DbConfig) -> anyhow::Result { let mut opts = Options::default(); + let mut block_based_options = BlockBasedOptions::default(); opts.create_if_missing(true); opts.increase_parallelism(4); @@ -36,9 +38,14 @@ impl Deserialize<'de> + std::hash::Hash + Eq, V: Seriali opts.set_max_bytes_for_level_base(512 * 1024 * 1024); // 512MB opts.set_max_open_files(100); } - DbConfig::Default => {} // Default options are already set + DbConfig::Default => { + block_based_options.set_block_size(16 * 1024); + block_based_options.set_ribbon_filter(15.5); // https://github.com/facebook/rocksdb/wiki/RocksDB-Bloom-Filter + } } + opts.set_block_based_table_factory(&block_based_options); + let db = DB::open(&opts, db_path)?; Ok(RocksDb { db, _marker: PhantomData })