From a30df11e225d2fc9d720d951e8593e7a4737d8f2 Mon Sep 17 00:00:00 2001 From: wathenjiang Date: Mon, 25 Sep 2023 14:29:58 +0800 Subject: [PATCH] make spawn_concurrency_level is constant 4 in loom test --- tokio/src/runtime/builder.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tokio/src/runtime/builder.rs b/tokio/src/runtime/builder.rs index cc3fcf06a8d..e69b22950aa 100644 --- a/tokio/src/runtime/builder.rs +++ b/tokio/src/runtime/builder.rs @@ -1284,6 +1284,11 @@ cfg_rt_multi_thread! { use crate::runtime::scheduler::{self, MultiThread}; let core_threads = self.worker_threads.unwrap_or_else(num_cpus); + // Shrink the size of spawn_concurrency_level when using loom. This shouldn't impact + // logic, but allows loom to test more edge cases in a reasoable a mount of time + #[cfg(loom)] + let spawn_concurrency_level = 4; + #[cfg(not(loom))] let spawn_concurrency_level = self.spawn_concurrency_level.unwrap_or(core_threads * 4); let (driver, driver_handle) = driver::Driver::new(self.get_cfg())?; @@ -1334,6 +1339,12 @@ cfg_rt_multi_thread! { use crate::runtime::scheduler::MultiThreadAlt; let core_threads = self.worker_threads.unwrap_or_else(num_cpus); + + // Shrink the size of spawn_concurrency_level when using loom. This shouldn't impact + // logic, but allows loom to test more edge cases in a reasoable a mount of time + #[cfg(loom)] + let spawn_concurrency_level = 4; + #[cfg(not(loom))] let spawn_concurrency_level = self.spawn_concurrency_level.unwrap_or(core_threads * 4); let (driver, driver_handle) = driver::Driver::new(self.get_cfg())?;