add rocksdb compaction thread priority/iopriority w/ conf
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
a4c243cae5
commit
54eb634588
4 changed files with 34 additions and 3 deletions
|
@ -387,6 +387,14 @@ allow_profile_lookup_federation_requests = true
|
||||||
# Defaults to your CPU physical core count (not logical threads).
|
# Defaults to your CPU physical core count (not logical threads).
|
||||||
#rocksdb_parallelism_threads = 0
|
#rocksdb_parallelism_threads = 0
|
||||||
|
|
||||||
|
# Enables idle IO priority for compaction thread. This prevents any unexpected lag in the server's operation and
|
||||||
|
# is usually a good idea. Enabled by default.
|
||||||
|
#rocksdb_compaction_ioprio_idle = true
|
||||||
|
|
||||||
|
# Enables idle CPU priority for compaction thread. This is not enabled by default to prevent compaction from
|
||||||
|
# falling too far behind on busy systems.
|
||||||
|
#rocksdb_compaction_prio_idle = false
|
||||||
|
|
||||||
# Maximum number of LOG files RocksDB will keep. This must *not* be set to 0. It must be at least 1.
|
# Maximum number of LOG files RocksDB will keep. This must *not* be set to 0. It must be at least 1.
|
||||||
# Defaults to 3 as these are not very useful.
|
# Defaults to 3 as these are not very useful.
|
||||||
#rocksdb_max_log_files = 3
|
#rocksdb_max_log_files = 3
|
||||||
|
|
|
@ -228,6 +228,10 @@ pub(crate) struct Config {
|
||||||
pub(crate) rocksdb_read_only: bool,
|
pub(crate) rocksdb_read_only: bool,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub(crate) rocksdb_periodic_cleanup: bool,
|
pub(crate) rocksdb_periodic_cleanup: bool,
|
||||||
|
#[serde(default)]
|
||||||
|
pub(crate) rocksdb_compaction_prio_idle: bool,
|
||||||
|
#[serde(default = "true_fn")]
|
||||||
|
pub(crate) rocksdb_compaction_ioprio_idle: bool,
|
||||||
|
|
||||||
pub(crate) emergency_password: Option<String>,
|
pub(crate) emergency_password: Option<String>,
|
||||||
|
|
||||||
|
@ -706,9 +710,22 @@ impl fmt::Display for Config {
|
||||||
),
|
),
|
||||||
#[cfg(feature = "rocksdb")]
|
#[cfg(feature = "rocksdb")]
|
||||||
("RocksDB Recovery Mode", &self.rocksdb_recovery_mode.to_string()),
|
("RocksDB Recovery Mode", &self.rocksdb_recovery_mode.to_string()),
|
||||||
|
#[cfg(feature = "rocksdb")]
|
||||||
("RocksDB Repair Mode", &self.rocksdb_repair.to_string()),
|
("RocksDB Repair Mode", &self.rocksdb_repair.to_string()),
|
||||||
|
#[cfg(feature = "rocksdb")]
|
||||||
("RocksDB Read-only Mode", &self.rocksdb_read_only.to_string()),
|
("RocksDB Read-only Mode", &self.rocksdb_read_only.to_string()),
|
||||||
|
#[cfg(feature = "rocksdb")]
|
||||||
("RocksDB Periodic Cleanup", &self.rocksdb_periodic_cleanup.to_string()),
|
("RocksDB Periodic Cleanup", &self.rocksdb_periodic_cleanup.to_string()),
|
||||||
|
#[cfg(feature = "rocksdb")]
|
||||||
|
(
|
||||||
|
"RocksDB Compaction Idle Priority",
|
||||||
|
&self.rocksdb_compaction_prio_idle.to_string(),
|
||||||
|
),
|
||||||
|
#[cfg(feature = "rocksdb")]
|
||||||
|
(
|
||||||
|
"RocksDB Compaction Idle IOPriority",
|
||||||
|
&self.rocksdb_compaction_ioprio_idle.to_string(),
|
||||||
|
),
|
||||||
("Prevent Media Downloads From", {
|
("Prevent Media Downloads From", {
|
||||||
let mut lst = vec![];
|
let mut lst = vec![];
|
||||||
for domain in &self.prevent_media_downloads_from {
|
for domain in &self.prevent_media_downloads_from {
|
||||||
|
|
|
@ -41,9 +41,9 @@ impl KeyValueDatabaseEngine for Arc<Engine> {
|
||||||
let mut col_cache = HashMap::new();
|
let mut col_cache = HashMap::new();
|
||||||
col_cache.insert("primary".to_owned(), Cache::new_lru_cache(col_cache_capacity_bytes));
|
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 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();
|
let load_time = std::time::Instant::now();
|
||||||
if config.rocksdb_repair {
|
if config.rocksdb_repair {
|
||||||
|
|
|
@ -14,7 +14,7 @@ use super::Config;
|
||||||
/// resulting value. Note that we require special per-column options on some
|
/// resulting value. Note that we require special per-column options on some
|
||||||
/// columns, therefor columns should only be opened after passing this result
|
/// columns, therefor columns should only be opened after passing this result
|
||||||
/// through cf_options().
|
/// 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();
|
let mut opts = Options::default();
|
||||||
|
|
||||||
// Logging
|
// 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_background_jobs(threads.try_into().unwrap());
|
||||||
opts.set_max_subcompactions(threads.try_into().unwrap());
|
opts.set_max_subcompactions(threads.try_into().unwrap());
|
||||||
opts.set_max_file_opening_threads(0);
|
opts.set_max_file_opening_threads(0);
|
||||||
|
if config.rocksdb_compaction_prio_idle {
|
||||||
|
env.lower_thread_pool_cpu_priority();
|
||||||
|
}
|
||||||
|
|
||||||
// IO
|
// IO
|
||||||
opts.set_manual_wal_flush(true);
|
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_skip_stats_update_on_db_open(true);
|
||||||
//opts.set_max_file_opening_threads(threads.try_into().unwrap());
|
//opts.set_max_file_opening_threads(threads.try_into().unwrap());
|
||||||
}
|
}
|
||||||
|
if config.rocksdb_compaction_ioprio_idle {
|
||||||
|
env.lower_thread_pool_io_priority();
|
||||||
|
}
|
||||||
|
|
||||||
// Blocks
|
// Blocks
|
||||||
let mut table_opts = table_options(config);
|
let mut table_opts = table_options(config);
|
||||||
|
|
Loading…
Add table
Reference in a new issue