Skip to content

Commit af5b7a7

Browse files
Jouzoprasannavl
andauthored
Update rocksdb default options (#3104)
* Cleanup * Restore without result * Comment out blob related options * Set rocksdb options max_open_files to 128 * Update vsdb * Set rocksdb options max_open_files to 256 --------- Co-authored-by: Prasanna Loganathar <pvl@prasannavl.com>
1 parent f1c38f4 commit af5b7a7

File tree

2 files changed

+35
-30
lines changed

2 files changed

+35
-30
lines changed

lib/Cargo.lock

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ain-db/src/lib.rs

+31-26
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,46 @@ pub mod version;
1010
use anyhow::format_err;
1111
use log::debug;
1212
use rocksdb::{
13-
BlockBasedOptions, Cache, ColumnFamily, ColumnFamilyDescriptor, DBIterator, Direction,
14-
IteratorMode, Options, DB,
13+
BlockBasedOptions, Cache, ColumnFamily, ColumnFamilyDescriptor, DBCompressionType, DBIterator,
14+
Direction, IteratorMode, Options, DB,
1515
};
1616
use serde::{de::DeserializeOwned, Serialize};
1717
use sha2::{Digest, Sha256};
1818

1919
pub type Result<T> = result::Result<T, DBError>;
2020

2121
fn get_db_default_options() -> Options {
22-
let mut options = Options::default();
23-
options.create_if_missing(true);
24-
options.create_missing_column_families(true);
25-
26-
let n = num_cpus::get();
27-
options.increase_parallelism(n as i32);
28-
29-
let mut env = rocksdb::Env::new().unwrap();
30-
31-
// While a compaction is ongoing, all the background threads
32-
// could be used by the compaction. This can stall writes which
33-
// need to flush the memtable. Add some high-priority background threads
34-
// which can service these writes.
35-
env.set_high_priority_background_threads(4);
36-
options.set_env(&env);
37-
38-
// Set max total wal size to 4G.
39-
options.set_max_total_wal_size(4 * 1024 * 1024 * 1024);
40-
41-
let cache = Cache::new_lru_cache(512 * 1024 * 1024);
4222
let mut block_opts = BlockBasedOptions::default();
43-
block_opts.set_block_cache(&cache);
44-
block_opts.set_bloom_filter(10.0, false);
45-
options.set_block_based_table_factory(&block_opts);
4623

47-
options
24+
block_opts.set_block_size(64 << 10); // kb
25+
block_opts.set_block_cache(&Cache::new_lru_cache(64 << 20)); // mb
26+
block_opts.set_cache_index_and_filter_blocks(true);
27+
block_opts.set_bloom_filter(10.0, true);
28+
// block_opts.set_pin_top_level_index_and_filter(true);
29+
30+
let mut opts = Options::default();
31+
32+
opts.set_max_open_files(256);
33+
34+
opts.create_if_missing(true);
35+
opts.create_missing_column_families(true);
36+
opts.set_write_buffer_size(64 << 20); // mb
37+
opts.set_max_write_buffer_number(2);
38+
// opts.set_min_blob_size(2 << 10); // kb
39+
// // opts.set_blob_file_size(256 << 20); // mb
40+
// opts.set_enable_blob_files(true);
41+
// opts.set_enable_blob_gc(true);
42+
opts.set_enable_pipelined_write(true);
43+
44+
opts.set_compression_type(DBCompressionType::Lz4);
45+
// opts.set_blob_compression_type(DBCompressionType::Lz4);
46+
opts.set_bottommost_compression_type(DBCompressionType::Zstd);
47+
opts.set_block_based_table_factory(&block_opts);
48+
opts.enable_statistics();
49+
let n = num_cpus::get();
50+
opts.increase_parallelism(n as i32);
51+
opts.set_level_compaction_dynamic_level_bytes(true);
52+
opts
4853
}
4954

5055
#[derive(Debug)]

0 commit comments

Comments
 (0)