Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase cache for RockDB by column #5212

Merged
merged 7 commits into from
Nov 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions core/store/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,22 +657,30 @@ fn rocksdb_read_options() -> ReadOptions {
read_options
}

fn rocksdb_block_based_options() -> BlockBasedOptions {
fn rocksdb_block_based_options(cache_size: usize) -> BlockBasedOptions {
let mut block_opts = BlockBasedOptions::default();
block_opts.set_block_size(1024 * 16);
// We create block_cache for each of 47 columns, so the total cache size is 32 * 47 = 1504mb
let cache_size = 1024 * 1024 * 32;
block_opts.set_block_cache(&Cache::new_lru_cache(cache_size).unwrap());
block_opts.set_pin_l0_filter_and_index_blocks_in_cache(true);
block_opts.set_cache_index_and_filter_blocks(true);
block_opts.set_bloom_filter(10, true);
block_opts
}

// TODO(#5213) Use ByteSize package to represent sizes.
fn choose_cache_size(col: DBCol) -> usize {
match col {
DBCol::ColState => 512 * 1024 * 1024,
_ => 32 * 1024 * 1024,
}
}

fn rocksdb_column_options(col: DBCol) -> Options {
let mut opts = Options::default();
opts.set_level_compaction_dynamic_level_bytes(true);
opts.set_block_based_table_factory(&rocksdb_block_based_options());
let cache_size = choose_cache_size(col);
opts.set_block_based_table_factory(&rocksdb_block_based_options(cache_size));
opts.optimize_level_style_compaction(1024 * 1024 * 128);
opts.set_target_file_size_base(1024 * 1024 * 64);
opts.set_compression_per_level(&[]);
Expand Down