From e70b520e5d92f0f1a755413404b875c7c2476c44 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Thu, 22 Oct 2026 07:57:47 +0200 Subject: [PATCH] Render thread ahead of the workers on macOS and Windows The client asks for its render thread what it already asks for the server thread (vanilla's MinecraftServer.spin): user-interactive QoS on macOS, above-normal priority on Windows, on machines with more than four processors. While terrain loads at 32 chunks, the worker pools (two with single player's server thread), the chunk encoders and other programs outnumber the cores. A frame that gave its core up in queue.submit then waited 10 to 200 ms to get one back: the long frames of #678. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/game.rs | 7 +++++++ crates/horizon-threads/src/lib.rs | 9 +++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index 2df6aa9b0..2ff15febc 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -12756,6 +12756,13 @@ pub fn run() -> Result<()> { if options.dedicated.is_some() { // Before any worker starts: on Linux they go behind the server thread. horizon_threads::put_helpers_behind(); + } else { + // The render thread, like the server thread, ahead of the workers on + // macOS and Windows. While terrain loads, the worker pools (two with + // single player's server thread) and other programs outnumber the + // cores, and a frame that gave its core up (in a GPU submit) waited + // 10 to 200 ms to get one back. + horizon_threads::favour_current(); } let started = Instant::now(); horizon_client::spans::enable(options.spikes.is_some()); diff --git a/crates/horizon-threads/src/lib.rs b/crates/horizon-threads/src/lib.rs index d6cd135e0..6af6818cc 100644 --- a/crates/horizon-threads/src/lib.rs +++ b/crates/horizon-threads/src/lib.rs @@ -7,10 +7,11 @@ use std::sync::atomic::{AtomicBool, Ordering}; /// threads, as vanilla's `MinecraftServer.spin` does for its server thread /// (`Thread.setPriority(8)` when there are more than four processors), so /// world generation and chunk encoding on every other core don't hold a tick -/// back: user-interactive quality of service on macOS, above-normal priority -/// on Windows. Nothing elsewhere: Linux lets an unprivileged thread lower its -/// priority but not raise it (and the JVM leaves it there too). Whether the -/// OS took it. +/// back (the client asks the same for its render thread, so they don't hold +/// a frame back either): user-interactive quality of service on macOS, +/// above-normal priority on Windows. Nothing elsewhere: Linux lets an +/// unprivileged thread lower its priority but not raise it (and the JVM +/// leaves it there too). Whether the OS took it. pub fn favour_current() -> bool { if std::thread::available_parallelism().map_or(1, |n| n.get()) <= 4 { return false;