From fb450342bc55e04e8f6483982971a0b23cbe903b Mon Sep 17 00:00:00 2001 From: rdbtCVS <87152661+rdbtCVS@users.noreply.github.com> Date: Sat, 17 Oct 2026 20:37:20 +0100 Subject: [PATCH] Worker threads: leave a core for the render and server threads --- crates/horizon-client/src/graphics.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/crates/horizon-client/src/graphics.rs b/crates/horizon-client/src/graphics.rs index f10c6b3b3..33b4b9dc9 100644 --- a/crates/horizon-client/src/graphics.rs +++ b/crates/horizon-client/src/graphics.rs @@ -271,9 +271,14 @@ impl Graphics { if self.workers > 0 { return self.workers as usize; } + // The pool never takes every core. The render thread and the + // integrated server thread (single player runs on its own server + // thread by default) each need one, and a pool that fills every core + // starves them: the frame rate collapses to single digits while the + // workers saturate the CPU and its memory bandwidth. let auto = std::thread::available_parallelism() .map_or(2, |n| n.get()) - .saturating_sub(1) + .saturating_sub(2) .max(1); if self.battery { auto.div_ceil(2) } else { auto } } @@ -357,6 +362,17 @@ mod tests { ); } + #[test] + fn automatic_workers_leave_cores_for_the_render_and_server_threads() { + let g = Graphics::default(); + assert_eq!(g.workers, 0); + let cores = std::thread::available_parallelism().map_or(2, |n| n.get()); + assert_eq!(g.worker_threads(), cores.saturating_sub(2).max(1)); + // A manual count is the player's own choice, kept as asked. + let manual = Graphics { workers: 3, ..g }; + assert_eq!(manual.worker_threads(), 3); + } + #[test] fn battery_mode_only_lowers_the_frame_cap() { let mut g = Graphics::default();