From 9f245281b158d49121a22935369d6c4b516a9b79 Mon Sep 17 00:00:00 2001 From: strawberry Date: Fri, 26 Apr 2024 16:55:37 -0400 Subject: [PATCH] never allow only 1 tokio worker or rocksdb parallelism thread (max compare) Signed-off-by: strawberry --- src/database/rocksdb/opts.rs | 2 +- src/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/database/rocksdb/opts.rs b/src/database/rocksdb/opts.rs index 2c8b793c..ea4a0dea 100644 --- a/src/database/rocksdb/opts.rs +++ b/src/database/rocksdb/opts.rs @@ -22,7 +22,7 @@ pub(crate) fn db_options(config: &Config, env: &mut Env, row_cache: &Cache, col_ // Processing let threads = if config.rocksdb_parallelism_threads == 0 { - num_cpus::get() // max cores if user specified 0 + std::cmp::max(2, num_cpus::get()) // max cores if user specified 0 } else { config.rocksdb_parallelism_threads }; diff --git a/src/main.rs b/src/main.rs index af235146..bf2f40db 100644 --- a/src/main.rs +++ b/src/main.rs @@ -515,7 +515,7 @@ fn init(args: clap::Args) -> Result { .enable_io() .enable_time() .thread_name("conduwuit:worker") - .worker_threads(num_cpus::get()) + .worker_threads(std::cmp::max(2, num_cpus::get())) .build() .unwrap(),