Skip to content

Commit

Permalink
test cuckoo table format
Browse files Browse the repository at this point in the history
  • Loading branch information
carneiro-cw committed Nov 14, 2024
1 parent e79bcb6 commit 4a82465
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/eth/storage/rocks/rocks_config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use rocksdb::BlockBasedOptions;
use rocksdb::Cache;
use rocksdb::CuckooTableOptions;
use rocksdb::Options;

pub enum CacheSetting {
Expand All @@ -21,16 +22,12 @@ impl Default for DbConfig {
}

impl DbConfig {
pub fn to_options(self, cache_setting: CacheSetting) -> Options {
pub fn to_options(self, _cache_setting: CacheSetting) -> Options {
let mut opts = Options::default();
let mut block_based_options = BlockBasedOptions::default();

opts.create_if_missing(true);
opts.create_missing_column_families(true);
opts.increase_parallelism(16);
block_based_options.set_pin_l0_filter_and_index_blocks_in_cache(true);
block_based_options.set_cache_index_and_filter_blocks(true);
block_based_options.set_ribbon_filter(15.5);

// NOTE: As per the rocks db wiki: "The overhead of statistics is usually small but non-negligible. We usually observe an overhead of 5%-10%."
#[cfg(feature = "metrics")]
Expand All @@ -41,22 +38,27 @@ impl DbConfig {

match self {
DbConfig::OptimizedPointLookUp => {
let mut cuckoo = CuckooTableOptions::default();
cuckoo.set_hash_ratio(0.5);
cuckoo.set_max_search_depth(200);
opts.set_compression_type(rocksdb::DBCompressionType::None);
opts.set_cuckoo_table_factory(&cuckoo);
}
DbConfig::Default => {

let mut block_based_options = BlockBasedOptions::default();

block_based_options.set_pin_l0_filter_and_index_blocks_in_cache(true);
block_based_options.set_cache_index_and_filter_blocks(true);
block_based_options.set_ribbon_filter(15.5);

opts.set_compression_type(rocksdb::DBCompressionType::Lz4);
opts.set_bottommost_compression_type(rocksdb::DBCompressionType::Zstd);
opts.set_bottommost_compression_options(-14, 32767, 0, 16 * 1024, true); // mostry defaults except max_dict_bytes
opts.set_bottommost_compression_options(-14, 32767, 0, 16 * 1024, true); // mostly defaults except max_dict_bytes
opts.set_bottommost_zstd_max_train_bytes(1600 * 1024, true);
}
}

if let CacheSetting::Enabled(cache_size) = cache_setting {
let cache = Cache::new_lru_cache(cache_size);
block_based_options.set_block_cache(&cache);
}

opts.set_block_based_table_factory(&block_based_options);
opts
}
}

0 comments on commit 4a82465

Please sign in to comment.