Tune level-style database file compaction (#4045)
This commit is contained in:
parent
73aea46458
commit
6d2c4fbb5f
|
@ -346,6 +346,11 @@ impl DiskDb {
|
|||
/// stdio (3), and other OS facilities (2+).
|
||||
const RESERVED_FILE_COUNT: u64 = 48;
|
||||
|
||||
/// The size of the database memtable RAM cache in megabytes.
|
||||
///
|
||||
/// https://github.com/facebook/rocksdb/wiki/RocksDB-FAQ#configuration-and-tuning
|
||||
const MEMTABLE_RAM_CACHE_MEGABYTES: usize = 128;
|
||||
|
||||
/// Opens or creates the database at `config.path` for `network`,
|
||||
/// and returns a shared low-level database wrapper.
|
||||
pub fn new(config: &Config, network: Network) -> DiskDb {
|
||||
|
@ -455,6 +460,8 @@ impl DiskDb {
|
|||
let mut opts = rocksdb::Options::default();
|
||||
let mut block_based_opts = rocksdb::BlockBasedOptions::default();
|
||||
|
||||
const ONE_MEGABYTE: usize = 1024 * 1024;
|
||||
|
||||
opts.create_if_missing(true);
|
||||
opts.create_missing_column_families(true);
|
||||
|
||||
|
@ -469,6 +476,11 @@ impl DiskDb {
|
|||
// https://github.com/facebook/rocksdb/wiki/Compression#configuration
|
||||
opts.set_compression_type(rocksdb::DBCompressionType::Lz4);
|
||||
|
||||
// Tune level-style database file compaction.
|
||||
//
|
||||
// This improves Zebra's initial sync speed slightly, as of April 2022.
|
||||
opts.optimize_level_style_compaction(Self::MEMTABLE_RAM_CACHE_MEGABYTES * ONE_MEGABYTE);
|
||||
|
||||
// Increase the process open file limit if needed,
|
||||
// then use it to set RocksDB's limit.
|
||||
let open_file_limit = DiskDb::increase_open_file_limit();
|
||||
|
|
Loading…
Reference in New Issue