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;