Improve concurrency for larger systems

This commit is contained in:
asonix 2022-11-20 12:06:10 -06:00
parent d44db2eab5
commit df3063e75f

View file

@ -44,9 +44,8 @@ pub(crate) fn create_workers(
media: MediaCache, media: MediaCache,
config: Config, config: Config,
) -> (Manager, JobServer) { ) -> (Manager, JobServer) {
let parallelism = std::thread::available_parallelism() let parallelism =
.map(|p| p.get()) std::thread::available_parallelism().unwrap_or(NonZeroUsize::try_from(1).expect("nonzero"));
.unwrap_or(1) as u64;
let shared = WorkerConfig::new_managed(Storage::new(ActixTimer), move |queue_handle| { let shared = WorkerConfig::new_managed(Storage::new(ActixTimer), move |queue_handle| {
JobState::new( JobState::new(
@ -68,10 +67,10 @@ pub(crate) fn create_workers(
.register::<apub::Forward>() .register::<apub::Forward>()
.register::<apub::Reject>() .register::<apub::Reject>()
.register::<apub::Undo>() .register::<apub::Undo>()
.set_worker_count("maintenance", parallelism * 2) .set_worker_count("maintenance", 2)
.set_worker_count("apub", parallelism * 2) .set_worker_count("apub", 2)
.set_worker_count("deliver", parallelism * 8) .set_worker_count("deliver", 8)
.start_with_threads(NonZeroUsize::try_from(parallelism as usize).expect("nonzero")); .start_with_threads(parallelism);
shared.every(Duration::from_secs(60 * 5), Listeners); shared.every(Duration::from_secs(60 * 5), Listeners);