[PR #7383] [MERGED] One worker_count() behind the pools' available_parallelism reads #7569

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7383
Author: @socksprox
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: t3/centralize-worker-thread-count


📝 Commits (2)

  • 1398532 One worker_count() behind the pools' available_parallelism reads
  • c09ee1f Merge main into #7383

📊 Changes

9 files changed (+62 additions, -21 deletions)

View changed files

📝 crates/horizon-client-render/src/graphics.rs (+2 -5)
📝 crates/horizon-client-render/src/lod.rs (+1 -1)
📝 crates/horizon-client-render/src/par.rs (+1 -3)
📝 crates/horizon-client/src/lan/chunks.rs (+1 -1)
📝 crates/horizon-client/src/mod_content.rs (+1 -1)
📝 crates/horizon-client/src/save.rs (+2 -2)
📝 crates/horizon-client/src/vanillagen/lod.rs (+1 -3)
📝 crates/horizon-threads/src/jobs.rs (+1 -4)
📝 crates/horizon-threads/src/lib.rs (+52 -1)

📄 Description

🤖 Opened by socksprox's AI agent (Devin, SWE-2 High), not by socksprox personally.

What and why

Fixes #7379.

Nine call sites each read std::thread::available_parallelism and sized their own pools, oversubscribing low-core machines with no way to cap them. horizon_threads::worker_count() now resolves the count once (a OnceLock: the machine a run got doesn't change, and a late read can't disagree with pools already started) and honors HORIZON_WORKER_THREADS to set it directly. Every site keeps its own share formula unchanged:

  • jobs::default_threads (the shared streaming pool) — all cores but one; HORIZON_JOB_THREADS still wins for it
  • vanillagen/lod decoration builder — a third, clamped to 12
  • save::compress_records — half, capped by record count
  • lan/chunks warm-up pool — cores minus one
  • Graphics::worker_threads — all but one
  • render lod scheduler, par_map, mod_content tables — the raw count with their own caps

Reads that report the machine (crash.rs, telemetry, benches) keep available_parallelism.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

Horizon-only. Vanilla sizes its pools off Runtime.availableProcessors with no override; the formulas mirroring it (Util.maxAllowedExecutorThreads) are unchanged.

Other projects' code

none

Self-check

python3 tools/pr_ready.py --quick (MacBookPro, against origin/main at 865b05bd4, 2 min 20 s)

Check Result
Scope ✅ 9 files, +62 −21
Cargo.lock ✅ unchanged
Public tree ✅ (1 s)
Python tests ✅ 612 passed (1 min 10 s)
rustfmt ✅ (9 s)
clippy ✅ (1 s)
tests: horizon-client-lib, horizon-client-render, horizon-threads ✅ 2635 passed (54 s)
doc tests ✅ 0 passed (3 s)
content root tests ✅ 24 passed (1 s)
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses

🤖 Generated with Devin


🔄 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/7383 **Author:** [@socksprox](https://github.com/socksprox) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `t3/centralize-worker-thread-count` --- ### 📝 Commits (2) - [`1398532`](https://github.com/horizon-rust/horizon/commit/139853213f395dd53e357e148c576eba701a0f26) One worker_count() behind the pools' available_parallelism reads - [`c09ee1f`](https://github.com/horizon-rust/horizon/commit/c09ee1f683c5279b63f08a63913a558da5e8749f) Merge main into #7383 ### 📊 Changes **9 files changed** (+62 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/graphics.rs` (+2 -5) 📝 `crates/horizon-client-render/src/lod.rs` (+1 -1) 📝 `crates/horizon-client-render/src/par.rs` (+1 -3) 📝 `crates/horizon-client/src/lan/chunks.rs` (+1 -1) 📝 `crates/horizon-client/src/mod_content.rs` (+1 -1) 📝 `crates/horizon-client/src/save.rs` (+2 -2) 📝 `crates/horizon-client/src/vanillagen/lod.rs` (+1 -3) 📝 `crates/horizon-threads/src/jobs.rs` (+1 -4) 📝 `crates/horizon-threads/src/lib.rs` (+52 -1) </details> ### 📄 Description > 🤖 Opened by socksprox's AI agent (Devin, SWE-2 High), not by socksprox personally. ## What and why Fixes #7379. Nine call sites each read `std::thread::available_parallelism` and sized their own pools, oversubscribing low-core machines with no way to cap them. `horizon_threads::worker_count()` now resolves the count once (a `OnceLock`: the machine a run got doesn't change, and a late read can't disagree with pools already started) and honors `HORIZON_WORKER_THREADS` to set it directly. Every site keeps its own share formula unchanged: - `jobs::default_threads` (the shared streaming pool) — all cores but one; `HORIZON_JOB_THREADS` still wins for it - `vanillagen/lod` decoration builder — a third, clamped to 12 - `save::compress_records` — half, capped by record count - `lan/chunks` warm-up pool — cores minus one - `Graphics::worker_threads` — all but one - render `lod` scheduler, `par_map`, `mod_content` tables — the raw count with their own caps Reads that report the machine (`crash.rs`, telemetry, benches) keep `available_parallelism`. ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [x] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference Horizon-only. Vanilla sizes its pools off `Runtime.availableProcessors` with no override; the formulas mirroring it (`Util.maxAllowedExecutorThreads`) are unchanged. ## Other projects' code none ## Self-check `python3 tools/pr_ready.py --quick` (MacBookPro, against origin/main at 865b05bd4, 2 min 20 s) | Check | Result | | --- | --- | | Scope | ✅ 9 files, +62 −21 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ (1 s) | | Python tests | ✅ 612 passed (1 min 10 s) | | rustfmt | ✅ (9 s) | | clippy | ✅ (1 s) | | tests: horizon-client-lib, horizon-client-render, horizon-threads | ✅ 2635 passed (54 s) | | doc tests | ✅ 0 passed (3 s) | | content root tests | ✅ 24 passed (1 s) | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | 🤖 Generated with [Devin](https://devin.ai) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 07:19:59 +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#7569
No description provided.