Skip to content

Commit

Permalink
Merge branch 'main' of github.com:cloudwalk/stratus
Browse files Browse the repository at this point in the history
  • Loading branch information
carneiro-cw committed Apr 1, 2024
2 parents 9ebf947 + 2010be9 commit ff56df1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/eth/storage/hybrid/rocks_db.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::marker::PhantomData;

use anyhow::Result;
use rocksdb::BlockBasedOptions;
use rocksdb::DBIteratorWithThreadMode;
use rocksdb::IteratorMode;
use rocksdb::Options;
Expand All @@ -23,6 +24,7 @@ pub struct RocksDb<K, V> {
impl<K: Serialize + for<'de> Deserialize<'de> + std::hash::Hash + Eq, V: Serialize + for<'de> Deserialize<'de> + Clone> RocksDb<K, V> {
pub fn new(db_path: &str, config: DbConfig) -> anyhow::Result<Self> {
let mut opts = Options::default();
let mut block_based_options = BlockBasedOptions::default();

opts.create_if_missing(true);
opts.increase_parallelism(4);
Expand All @@ -36,9 +38,14 @@ impl<K: Serialize + for<'de> 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 })
Expand Down

0 comments on commit ff56df1

Please sign in to comment.