From df3063e75fb96959d52a70516c9effa7352c2413 Mon Sep 17 00:00:00 2001 From: asonix Date: Sun, 20 Nov 2022 12:06:10 -0600 Subject: [PATCH] Improve concurrency for larger systems --- src/jobs.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/jobs.rs b/src/jobs.rs index b82d820..073dca8 100644 --- a/src/jobs.rs +++ b/src/jobs.rs @@ -44,9 +44,8 @@ pub(crate) fn create_workers( media: MediaCache, config: Config, ) -> (Manager, JobServer) { - let parallelism = std::thread::available_parallelism() - .map(|p| p.get()) - .unwrap_or(1) as u64; + let parallelism = + std::thread::available_parallelism().unwrap_or(NonZeroUsize::try_from(1).expect("nonzero")); let shared = WorkerConfig::new_managed(Storage::new(ActixTimer), move |queue_handle| { JobState::new( @@ -68,10 +67,10 @@ pub(crate) fn create_workers( .register::() .register::() .register::() - .set_worker_count("maintenance", parallelism * 2) - .set_worker_count("apub", parallelism * 2) - .set_worker_count("deliver", parallelism * 8) - .start_with_threads(NonZeroUsize::try_from(parallelism as usize).expect("nonzero")); + .set_worker_count("maintenance", 2) + .set_worker_count("apub", 2) + .set_worker_count("deliver", 8) + .start_with_threads(parallelism); shared.every(Duration::from_secs(60 * 5), Listeners);