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 <noreply@anthropic.com>
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user