add rocksdb compaction thread priority/iopriority w/ conf

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-04-24 23:29:09 -07:00 committed by June
parent a4c243cae5
commit 54eb634588
4 changed files with 34 additions and 3 deletions

View file

@ -41,9 +41,9 @@ impl KeyValueDatabaseEngine for Arc<Engine> {
let mut col_cache = HashMap::new();
col_cache.insert("primary".to_owned(), Cache::new_lru_cache(col_cache_capacity_bytes));
let db_env = Env::new()?;
let mut db_env = Env::new()?;
let row_cache = Cache::new_lru_cache(row_cache_capacity_bytes);
let db_opts = db_options(config, &db_env, &row_cache, col_cache.get("primary").expect("cache"));
let db_opts = db_options(config, &mut db_env, &row_cache, col_cache.get("primary").expect("cache"));
let load_time = std::time::Instant::now();
if config.rocksdb_repair {

View file

@ -14,7 +14,7 @@ use super::Config;
/// resulting value. Note that we require special per-column options on some
/// columns, therefor columns should only be opened after passing this result
/// through cf_options().
pub(crate) fn db_options(config: &Config, env: &Env, row_cache: &Cache, col_cache: &Cache) -> Options {
pub(crate) fn db_options(config: &Config, env: &mut Env, row_cache: &Cache, col_cache: &Cache) -> Options {
let mut opts = Options::default();
// Logging
@ -30,6 +30,9 @@ pub(crate) fn db_options(config: &Config, env: &Env, row_cache: &Cache, col_cach
opts.set_max_background_jobs(threads.try_into().unwrap());
opts.set_max_subcompactions(threads.try_into().unwrap());
opts.set_max_file_opening_threads(0);
if config.rocksdb_compaction_prio_idle {
env.lower_thread_pool_cpu_priority();
}
// IO
opts.set_manual_wal_flush(true);
@ -41,6 +44,9 @@ pub(crate) fn db_options(config: &Config, env: &Env, row_cache: &Cache, col_cach
opts.set_skip_stats_update_on_db_open(true);
//opts.set_max_file_opening_threads(threads.try_into().unwrap());
}
if config.rocksdb_compaction_ioprio_idle {
env.lower_thread_pool_io_priority();
}
// Blocks
let mut table_opts = table_options(config);