From d8105bb7d7985d0f217616041c44d201afff5c41 Mon Sep 17 00:00:00 2001 From: sakridge Date: Mon, 11 Jan 2021 13:32:02 -0800 Subject: [PATCH] Add rocskdb high priority threads (#14515) Without them, memtable writes can stall on compactions. --- ledger/src/blockstore_db.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ledger/src/blockstore_db.rs b/ledger/src/blockstore_db.rs index c53ed2c9d8..a6db8f2ace 100644 --- a/ledger/src/blockstore_db.rs +++ b/ledger/src/blockstore_db.rs @@ -1033,6 +1033,15 @@ fn get_db_options(access_type: &AccessType) -> Options { // A good value for this is the number of cores on the machine options.increase_parallelism(num_cpus::get() as i32); + let mut env = rocksdb::Env::default().unwrap(); + + // While a compaction is ongoing, all the background threads + // could be used by the compaction. This can stall writes which + // need to flush the memtable. Add some high-priority background threads + // which can service these writes. + env.set_high_priority_background_threads(4); + options.set_env(&env); + // Set max total wal size to 4G. options.set_max_total_wal_size(4 * 1024 * 1024 * 1024); if matches!(access_type, AccessType::PrimaryOnlyForMaintenance) {