Skip to content

Commit 1ce58a8

Browse files
authored
zed: Allocate more rayon threads depending on available parallelism (zed-industries#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 ...
1 parent a30887f commit 1ce58a8

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

crates/remote_server/src/unix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ pub fn execute_run(
373373
let listeners = ServerListeners::new(stdin_socket, stdout_socket, stderr_socket)?;
374374

375375
rayon::ThreadPoolBuilder::new()
376-
.num_threads(4)
376+
.num_threads(std::thread::available_parallelism().map_or(1, |n| n.get().div_ceil(2)))
377377
.stack_size(10 * 1024 * 1024)
378378
.thread_name(|ix| format!("RayonWorker{}", ix))
379379
.build_global()

crates/zed/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ pub fn main() {
265265
}
266266

267267
rayon::ThreadPoolBuilder::new()
268-
.num_threads(4)
268+
.num_threads(std::thread::available_parallelism().map_or(1, |n| n.get().div_ceil(2)))
269269
.stack_size(10 * 1024 * 1024)
270270
.thread_name(|ix| format!("RayonWorker{}", ix))
271271
.build_global()

0 commit comments

Comments
 (0)