[PR #354] [MERGED] Cap a fresh install at vanilla's 120 FPS #2515

Closed
opened 2026-11-02 15:56:49 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/cpu-defaults


📝 Commits (1)

  • 1573e4e Cap a fresh install at vanilla's 120 frames per second (#271)

📊 Changes

1 file changed (+13 additions, -2 deletions)

View changed files

📝 crates/horizon-client/src/settings.rs (+13 -2)

📄 Description

Part of #271

What

A fresh install (no options.txt) now caps the frame rate at vanilla's 120 instead of running unlimited (260).

Why

Settings::default() set max_fps: 260 ("Horizon runs unlimited unless capped"), while an options.txt without maxFps already gets vanilla's 120 (options_file.rs, vanilla Options.framerateLimit). VSync (on by default) hides it, but with VSync off, or when the surface doesn't pace (offscreen), the main thread drew up to 260 frames a second and kept a core busy.

The rest of #271, checked against vanilla 26.3

vanilla Horizon
background workers Util.maxAllowedExecutorThreads() = logical cores − 1 (worldgen, light and section compiles share it; GameRenderer gives section compiles up to one buffer pack per logical core, memory permitting) Graphics::worker_threads() = logical cores − 1 (generation, decoration, light, meshing), half in battery mode
other busy threads render thread, integrated server thread, IO worker main thread (renders and ticks), region writer
frame limit default 120 260 → 120 (this PR)
VSync default on on
menus without a world 60 fps (FramerateLimitTracker) 60 fps (same code)
idle limit AFK: 30 fps after a minute, 10 after 10 minutes same
frame limiter sleeps, then spins the last 0.5 ms sleeps in 50 µs steps instead (Efficient pacing, default)
workers waiting blocking queue Condvar wait, no spinning
thread priorities render thread Thread.MAX_PRIORITY (Minecraft.java:885), server 8, workers 5 (normal); the JVM applies them on Windows all threads normal priority

So Horizon starts fewer busy threads than vanilla and never spins. What vanilla does and Horizon doesn't is the last row: on Windows, vanilla's render thread outranks its 11 workers on a 6-core/12-thread CPU. That is what the reporter describes (11 workers + main thread at the same priority, the main thread waiting its turn). Matching it needs OS calls (SetThreadPriority, Linux setpriority): the client forbids unsafe, so it means a dependency (thread-priority, MIT; on Windows it uses the windows crate already in Cargo.lock). That is Ludovic's call and can't be verified on Windows from here, so it isn't in this PR.

Measurements

Process CPU over 20 s (all threads), game defaults (options.txt with only the render distance 12 and inactivityFpsLimit:minimized), Mac mini M4 Pro, offscreen:

main this PR
title screen 4.6 %, 4.6 % (46–52 fps, menu limit 60) 4.6 % (53 fps)
idle in a world, after loading 45.7 % at 58 fps, 47.0 % at 69 fps 51.3 % at 101 fps

These don't show the cap: other sessions kept the Mac mini at a load average of ~80, so main's uncapped loop never got near 120 fps either, and the runs differ in how busy the machine was (the last run was cut short by a restart). What the change does is arithmetic: with VSync off, every frame above 120 a second is no longer drawn. The title screen was already light (vanilla's 60 fps menu limit, no spinning).

How tested

cargo fmt --all -- --check                                   OK
cargo clippy --workspace --all-targets -- -D warnings        OK
cargo test -p horizon-client                                 all passed
  new: settings::no_options_txt_paces_frames_like_an_empty_one
parity.py --changed origin/main                         80 passed, 0 failed (one run on the merge
                                                             of this PR with its three siblings: #270 relight
                                                             remesh, #224 proto saves, #271 frame cap, spawn
                                                             heightmap; includes section_mesh, light, natural_spawn,
                                                             spawn_rules, world_spawn, frame_limiter, game_loop)

Needs Ludovic: whether to add thread-priority so the workers run below the main thread on Windows and Linux (vanilla's render-thread priority), for the rest of #271.

🤖 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/354 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/cpu-defaults` --- ### 📝 Commits (1) - [`1573e4e`](https://github.com/horizon-rust/horizon/commit/1573e4e5533ecd4eeba3c13f32f04f27cbb32e23) Cap a fresh install at vanilla's 120 frames per second (#271) ### 📊 Changes **1 file changed** (+13 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/settings.rs` (+13 -2) </details> ### 📄 Description Part of #271 ## What A fresh install (no `options.txt`) now caps the frame rate at vanilla's 120 instead of running unlimited (260). ## Why `Settings::default()` set `max_fps: 260` ("Horizon runs unlimited unless capped"), while an `options.txt` without `maxFps` already gets vanilla's 120 (`options_file.rs`, vanilla `Options.framerateLimit`). VSync (on by default) hides it, but with VSync off, or when the surface doesn't pace (offscreen), the main thread drew up to 260 frames a second and kept a core busy. ## The rest of #271, checked against vanilla 26.3 | | vanilla | Horizon | |---|---|---| | background workers | `Util.maxAllowedExecutorThreads()` = logical cores − 1 (worldgen, light and section compiles share it; `GameRenderer` gives section compiles up to one buffer pack per logical core, memory permitting) | `Graphics::worker_threads()` = logical cores − 1 (generation, decoration, light, meshing), half in battery mode | | other busy threads | render thread, integrated server thread, IO worker | main thread (renders and ticks), region writer | | frame limit default | 120 | 260 → **120** (this PR) | | VSync default | on | on | | menus without a world | 60 fps (`FramerateLimitTracker`) | 60 fps (same code) | | idle limit | AFK: 30 fps after a minute, 10 after 10 minutes | same | | frame limiter | sleeps, then spins the last 0.5 ms | sleeps in 50 µs steps instead (Efficient pacing, default) | | workers waiting | blocking queue | `Condvar` wait, no spinning | | thread priorities | render thread `Thread.MAX_PRIORITY` (`Minecraft.java:885`), server 8, workers 5 (normal); the JVM applies them on Windows | all threads normal priority | So Horizon starts fewer busy threads than vanilla and never spins. What vanilla does and Horizon doesn't is the last row: on Windows, vanilla's render thread outranks its 11 workers on a 6-core/12-thread CPU. That is what the reporter describes (11 workers + main thread at the same priority, the main thread waiting its turn). Matching it needs OS calls (`SetThreadPriority`, Linux `setpriority`): the client forbids `unsafe`, so it means a dependency (`thread-priority`, MIT; on Windows it uses the `windows` crate already in `Cargo.lock`). That is Ludovic's call and can't be verified on Windows from here, so it isn't in this PR. ## Measurements Process CPU over 20 s (all threads), game defaults (options.txt with only the render distance 12 and `inactivityFpsLimit:minimized`), Mac mini M4 Pro, offscreen: | | main | this PR | |---|---|---| | title screen | 4.6 %, 4.6 % (46–52 fps, menu limit 60) | 4.6 % (53 fps) | | idle in a world, after loading | 45.7 % at 58 fps, 47.0 % at 69 fps | 51.3 % at 101 fps | These don't show the cap: other sessions kept the Mac mini at a load average of ~80, so main's uncapped loop never got near 120 fps either, and the runs differ in how busy the machine was (the last run was cut short by a restart). What the change does is arithmetic: with VSync off, every frame above 120 a second is no longer drawn. The title screen was already light (vanilla's 60 fps menu limit, no spinning). ## How tested ``` cargo fmt --all -- --check OK cargo clippy --workspace --all-targets -- -D warnings OK cargo test -p horizon-client all passed new: settings::no_options_txt_paces_frames_like_an_empty_one parity.py --changed origin/main 80 passed, 0 failed (one run on the merge of this PR with its three siblings: #270 relight remesh, #224 proto saves, #271 frame cap, spawn heightmap; includes section_mesh, light, natural_spawn, spawn_rules, world_spawn, frame_limiter, game_loop) ``` **Needs Ludovic:** whether to add `thread-priority` so the workers run below the main thread on Windows and Linux (vanilla's render-thread priority), for the rest of #271. 🤖 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-02 15:56:49 +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#2515
No description provided.