change rocksdb stats level to 3

scale rocksdb background jobs and subcompactions

change rocksdb default error level to info from error

delete unused num_threads function

fix warns from cargo
This commit is contained in:
Jacob Taylor 2025-06-21 08:02:49 -07:00
parent b7004aa508
commit f29ed6568d
3 changed files with 8 additions and 22 deletions

View file

@ -990,7 +990,7 @@
# 3 to 5 = Statistics with possible performance impact. # 3 to 5 = Statistics with possible performance impact.
# 6 = All statistics. # 6 = All statistics.
# #
#rocksdb_stats_level = 1 #rocksdb_stats_level = 3
# This is a password that can be configured that will let you login to the # This is a password that can be configured that will let you login to the
# server bot account (currently `@conduit`) for emergency troubleshooting # server bot account (currently `@conduit`) for emergency troubleshooting

View file

@ -1155,7 +1155,7 @@ pub struct Config {
/// 3 to 5 = Statistics with possible performance impact. /// 3 to 5 = Statistics with possible performance impact.
/// 6 = All statistics. /// 6 = All statistics.
/// ///
/// default: 1 /// default: 3
#[serde(default = "default_rocksdb_stats_level")] #[serde(default = "default_rocksdb_stats_level")]
pub rocksdb_stats_level: u8, pub rocksdb_stats_level: u8,
@ -2199,7 +2199,7 @@ fn default_typing_client_timeout_max_s() -> u64 { 45 }
fn default_rocksdb_recovery_mode() -> u8 { 1 } fn default_rocksdb_recovery_mode() -> u8 { 1 }
fn default_rocksdb_log_level() -> String { "error".to_owned() } fn default_rocksdb_log_level() -> String { "info".to_owned() }
fn default_rocksdb_log_time_to_roll() -> usize { 0 } fn default_rocksdb_log_time_to_roll() -> usize { 0 }
@ -2231,7 +2231,7 @@ fn default_rocksdb_compression_level() -> i32 { 32767 }
#[allow(clippy::doc_markdown)] #[allow(clippy::doc_markdown)]
fn default_rocksdb_bottommost_compression_level() -> i32 { 32767 } fn default_rocksdb_bottommost_compression_level() -> i32 { 32767 }
fn default_rocksdb_stats_level() -> u8 { 1 } fn default_rocksdb_stats_level() -> u8 { 3 }
// I know, it's a great name // I know, it's a great name
#[must_use] #[must_use]

View file

@ -1,8 +1,6 @@
use std::{cmp, convert::TryFrom}; use conduwuit::{Config, Result};
use conduwuit::{Config, Result, utils};
use rocksdb::{Cache, DBRecoveryMode, Env, LogLevel, Options, statistics::StatsLevel}; use rocksdb::{Cache, DBRecoveryMode, Env, LogLevel, Options, statistics::StatsLevel};
use conduwuit::config::{parallelism_scaled_i32, parallelism_scaled_u32};
use super::{cf_opts::cache_size_f64, logger::handle as handle_log}; use super::{cf_opts::cache_size_f64, logger::handle as handle_log};
/// Create database-wide options suitable for opening the database. This also /// Create database-wide options suitable for opening the database. This also
@ -23,8 +21,8 @@ pub(crate) fn db_options(config: &Config, env: &Env, row_cache: &Cache) -> Resul
set_logging_defaults(&mut opts, config); set_logging_defaults(&mut opts, config);
// Processing // Processing
opts.set_max_background_jobs(num_threads::<i32>(config)?); opts.set_max_background_jobs(parallelism_scaled_i32(1));
opts.set_max_subcompactions(num_threads::<u32>(config)?); opts.set_max_subcompactions(parallelism_scaled_u32(1));
opts.set_avoid_unnecessary_blocking_io(true); opts.set_avoid_unnecessary_blocking_io(true);
opts.set_max_file_opening_threads(0); opts.set_max_file_opening_threads(0);
@ -126,15 +124,3 @@ fn set_logging_defaults(opts: &mut Options, config: &Config) {
opts.set_callback_logger(rocksdb_log_level, &handle_log); opts.set_callback_logger(rocksdb_log_level, &handle_log);
} }
} }
fn num_threads<T: TryFrom<usize>>(config: &Config) -> Result<T> {
const MIN_PARALLELISM: usize = 2;
let requested = if config.rocksdb_parallelism_threads != 0 {
config.rocksdb_parallelism_threads
} else {
utils::available_parallelism()
};
utils::math::try_into::<T, usize>(cmp::max(MIN_PARALLELISM, requested))
}