[PR #1778] [MERGED] Worker threads: leave one core, as vanilla does, not two #3754

Closed
opened 2026-11-03 04:12:04 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1778
Author: @ludovic111
Created: 10/25/2026
Status: ✅ Merged
Merged: 10/25/2026
Merged by: @ludovic111

Base: main ← Head: perf/worker-count


📝 Commits (1)

  • 1437537 Worker threads: leave one core, as vanilla does, not two

📊 Changes

1 file changed (+12 additions, -8 deletions)

View changed files

📝 crates/horizon-client/src/graphics.rs (+12 -8)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

By default, the worker pools now leave one core free, as vanilla does, instead of two.

Graphics::worker_threads sets the size of both single-player pools: the server thread's, which generates and lights chunks, and the window's, which meshes them. Its automatic count was cores - 2, chosen in #745 when a pool that filled every core starved the render thread. Vanilla's executor leaves one core (Util.maxAllowedExecutorThreads). The workers now run behind the server and render threads: niced on Linux, and on macOS and Windows above four cores the server and render threads are raised. With that in place, the second free core mostly sat idle. On a 4-thread laptop only 2 cores generated while a world loaded; perf at world entry showed 0.55 of a core idle.

A count set by hand (workers: in horizon-graphics.txt) is unchanged, and battery mode still halves the automatic count.

Measured

ThinkPad (i5-7200U, 2 cores / 4 threads, Intel HD 620), --offscreen, RD 12, seed 1234: perf_bench's village and ocean teleports, and horizon-ctl bench 10 over the first 10 s of each load (frame rate while loading). Runs alternate main and this branch, each started only on an idle machine (load < 1, no other Java), with automatic workers on both: 2 on main, 3 here.

main (2 workers) this branch (3 workers)
spawn load 36.6 / 36.2 s 32.2 / 30.0 s
village teleport 34.1 / 36.3 s 28.3 / 30.6 s
ocean teleport 34.4 / 34.3 s 33.2 / 30.7 s
FPS, first 10 s of each load (avg) 812 / 757 / 793 / 807 735 / 720 / 692 / 699
1% low, same 205 / 219 / 197 / 191 176 / 129 / 152 / 166

Means: teleport 34.8 → 30.7 s (−12%), spawn 36.4 → 31.1 s (−15%). The frame rate while loading drops 792 → 712 average (−10%) and 1% low 203 → 156 (−23%): the third worker takes CPU from the render thread on 2 physical cores. That is at the bench's unlimited frame rate. Players default to 120 FPS with VSync, which is far below both numbers.

Machine load: two clean pairs, each started at a 1-minute load below 1 with no other Java running. A third pair ran while another session's NeoForge jobs pushed the load to about 6 (main 48–52 s, this branch 28–31 s). It is left out of the means.

Not measured: macOS and Windows with 4 cores or fewer. There the server and render threads are not raised above the workers, so a third worker competes with them on equal terms.

Self-check

pr_ready (tools/pr_ready.py on ludovics-mac-mini, against origin/main at fbfec6435, 82 min 7 s)

Check Result
Scope ✅ 1 files, +12 −8
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (16 s)
clippy ✅ (1 min 43 s)
tests: horizon-client ✅ 1217 passed (6 min 27 s)
doc tests ✅ 0 passed (5 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ✅ 110 affected, 110 passed (73 min 13 s)
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/1778 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/25/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/worker-count` --- ### 📝 Commits (1) - [`1437537`](https://github.com/horizon-rust/horizon/commit/1437537cbfd16e349ee39eef7ec544fb6cb3fe01) Worker threads: leave one core, as vanilla does, not two ### 📊 Changes **1 file changed** (+12 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/graphics.rs` (+12 -8) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. By default, the worker pools now leave one core free, as vanilla does, instead of two. `Graphics::worker_threads` sets the size of both single-player pools: the server thread's, which generates and lights chunks, and the window's, which meshes them. Its automatic count was `cores - 2`, chosen in #745 when a pool that filled every core starved the render thread. Vanilla's executor leaves one core (`Util.maxAllowedExecutorThreads`). The workers now run behind the server and render threads: niced on Linux, and on macOS and Windows above four cores the server and render threads are raised. With that in place, the second free core mostly sat idle. On a 4-thread laptop only 2 cores generated while a world loaded; `perf` at world entry showed 0.55 of a core idle. A count set by hand (`workers:` in `horizon-graphics.txt`) is unchanged, and battery mode still halves the automatic count. ## Measured ThinkPad (i5-7200U, 2 cores / 4 threads, Intel HD 620), `--offscreen`, RD 12, seed 1234: `perf_bench`'s village and ocean teleports, and `horizon-ctl bench 10` over the first 10 s of each load (frame rate while loading). Runs alternate main and this branch, each started only on an idle machine (load < 1, no other Java), with automatic workers on both: 2 on main, 3 here. | | main (2 workers) | this branch (3 workers) | |---|---|---| | spawn load | 36.6 / 36.2 s | 32.2 / 30.0 s | | village teleport | 34.1 / 36.3 s | 28.3 / 30.6 s | | ocean teleport | 34.4 / 34.3 s | 33.2 / 30.7 s | | FPS, first 10 s of each load (avg) | 812 / 757 / 793 / 807 | 735 / 720 / 692 / 699 | | 1% low, same | 205 / 219 / 197 / 191 | 176 / 129 / 152 / 166 | Means: teleport 34.8 → 30.7 s (−12%), spawn 36.4 → 31.1 s (−15%). The frame rate while loading drops 792 → 712 average (−10%) and 1% low 203 → 156 (−23%): the third worker takes CPU from the render thread on 2 physical cores. That is at the bench's unlimited frame rate. Players default to 120 FPS with VSync, which is far below both numbers. Machine load: two clean pairs, each started at a 1-minute load below 1 with no other Java running. A third pair ran while another session's NeoForge jobs pushed the load to about 6 (main 48–52 s, this branch 28–31 s). It is left out of the means. Not measured: macOS and Windows with 4 cores or fewer. There the server and render threads are not raised above the workers, so a third worker competes with them on equal terms. ## Self-check **pr_ready** (`tools/pr_ready.py` on ludovics-mac-mini, against origin/main at fbfec6435, 82 min 7 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +12 −8 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (16 s) | | clippy | ✅ (1 min 43 s) | | tests: horizon-client | ✅ 1217 passed (6 min 27 s) | | doc tests | ✅ 0 passed (5 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ✅ 110 affected, 110 passed (73 min 13 s) | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:12:04 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#3754
No description provided.