Add rocskdb high priority threads (#14515)

Without them, memtable writes can stall on compactions.
This commit is contained in:
sakridge 2021-01-11 13:32:02 -08:00 committed by GitHub
parent 872a249e97
commit d8105bb7d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -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) {