From 1ce58a88ccdfb7e45106d66fa44c9db35b4f94b9 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 21 Nov 2025 11:33:38 +0100 Subject: [PATCH] zed: Allocate more rayon threads depending on available parallelism (#43235) While zed itself is not a heavy user of rayon, wasmtime is, especially for compilation. This change is similar to the rayon default but we halve the number of threads still so we don't spawn too many threads overall. Release Notes: - N/A *or* Added/Fixed/Improved ... --- crates/remote_server/src/unix.rs | 2 +- crates/zed/src/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/remote_server/src/unix.rs b/crates/remote_server/src/unix.rs index 29e5ef735f5a001c23e3215c1a3fc5d291830282..c631d47b8c2cea5d2ed74cd6ce8bd2956c3fbb1a 100644 --- a/crates/remote_server/src/unix.rs +++ b/crates/remote_server/src/unix.rs @@ -373,7 +373,7 @@ pub fn execute_run( let listeners = ServerListeners::new(stdin_socket, stdout_socket, stderr_socket)?; rayon::ThreadPoolBuilder::new() - .num_threads(4) + .num_threads(std::thread::available_parallelism().map_or(1, |n| n.get().div_ceil(2))) .stack_size(10 * 1024 * 1024) .thread_name(|ix| format!("RayonWorker{}", ix)) .build_global() diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 9dba1b427d35db3e236e166b5a90984deca1747b..89944f835b0c7905145b3c6c0df13a20c78f37b8 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -265,7 +265,7 @@ pub fn main() { } rayon::ThreadPoolBuilder::new() - .num_threads(4) + .num_threads(std::thread::available_parallelism().map_or(1, |n| n.get().div_ceil(2))) .stack_size(10 * 1024 * 1024) .thread_name(|ix| format!("RayonWorker{}", ix)) .build_global()