[PR #5800] [MERGED] The game can keep under a RAM limit #6506

Closed
opened 2026-11-03 06:21:45 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5800
Author: @1038april
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: feat/ram-limit-game


📝 Commits (4)

📊 Changes

12 files changed (+957 additions, -14 deletions)

View changed files

📝 crates/horizon-client-render/src/crash.rs (+24 -0)
📝 crates/horizon-client/src/game.rs (+14 -5)
📝 crates/horizon-client/src/game/chat.rs (+13 -0)
➕ crates/horizon-client/src/game/ram_limit.rs (+75 -0)
📝 crates/horizon-client/src/game/remote.rs (+11 -7)
📝 crates/horizon-client/src/lib.rs (+1 -0)
📝 crates/horizon-client/src/main.rs (+2 -1)
➕ crates/horizon-client/src/ram_limit.rs (+355 -0)
📝 crates/horizon-threads/Cargo.toml (+1 -1)
📝 crates/horizon-threads/src/lib.rs (+1 -0)
➕ crates/horizon-threads/src/memory_limit.rs (+449 -0)
📝 docs/native-client.md (+11 -0)

📄 Description

🤖 Opened by 1038april's AI agent (Claude Code, Opus 5.5), not by 1038april personally.

What and why

Part of #5798. The game side of a RAM limit; the launcher's row is in its own pull request.

HORIZON_MEMORY_LIMIT_MB and /ramlimit, /ramlimit <MB>, /ramlimit off limit the RAM the game holds. With neither set, nothing changes and no thread runs.

  • Windows: a hard working set limit (SetProcessWorkingSetSizeEx). The system moves what the game used least out of RAM, so a low limit costs speed instead of failing.
  • Slow and faulting hard on Windows, or nearing the limit elsewhere: far terrain goes off and the render distance in use drops, never the saved option. Both come back when there is room.
  • Crash, only as a last resort: on Windows, no frame for 60 s while faulting hard (the cap is lifted first so the report can be written). Elsewhere, 20 s over the limit with nothing left to give up. These reports don't go to crash telemetry, since the player chose the limit.
  • /ramlimit is answered by the window on any server, joins the chat's command list, and lasts until the game closes.

Measured on Windows with a real game teleporting to force new chunks, hidden window, render distance 12, limit set from launch:

Limit Peak RAM Result
none 1339 MB
1000 MB 999 MB no frames lost, render distance kept
500 MB 500 MB no frames lost
60 MB 60 MB choppy, render distance fell to 2 (before the last tuning of when it steps down)
20 MB 20 MB about 0-8 fps, still running
5 MB, 1 MB at the limit until the crash froze, then a crash report after about a minute

For review:

  • Memory moved out of RAM can go to the page file. Private bytes stayed around 3 GB, so this limits RAM, not total memory.
  • Linux and macOS have no such limit. There, chunks are the main thing to give up, and on Windows the game still held about 1250 MB at render distance 4, so a lower limit there would likely end in the last-resort crash.
  • The page fault thresholds come from this one machine.

Not tested: Linux and macOS, which I couldn't compile or run here (CI will be the first build); a normal visible window under load, since the runs above used a hidden one; a minimized game at a low limit; a real multiplayer server.

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. The window answers /ramlimit itself; vanilla's command tree is untouched.

Other projects' code

none

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main on KernelOS-PC, against upstream/main at 5edb339a7, 4 min 54 s)

Check Result
Scope ⚠️ 13 files, +934 −12; 935 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 511 passed (52 s)
rustfmt ✅ (8 s)
clippy ✅ (34 s)
tests: horizon-client, horizon-client-render, horizon-threads ❌ 1614 passed, 1 failed (3 min 14 s)
doc tests ✅ 0 passed (3 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The one failure isn't from this change: loot_table_load_stays_hookable searches a source file for a newline-delimited }, and a Windows checkout has CRLF. --quick, so harnesses weren't run. The size is over the guideline; a good part of it is tests.

🤖 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/5800 **Author:** [@1038april](https://github.com/1038april) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/ram-limit-game` --- ### 📝 Commits (4) - [`048a927`](https://github.com/horizon-rust/horizon/commit/048a9276d89e3705ef7d665f242d2029297d95d9) The game can keep under a RAM limit - [`01ae0bd`](https://github.com/horizon-rust/horizon/commit/01ae0bd7914c71d09f8f29b0712465ae2fe0918d) Merge main into #5800 - [`672fe27`](https://github.com/horizon-rust/horizon/commit/672fe27345eb0a8f97676847dfb96e8da47ddfae) Merge main into #5800; a RAM cap turned off or changed gets its whole grace again - [`1f629b5`](https://github.com/horizon-rust/horizon/commit/1f629b560dd1bda126fecb8894d63feba110562b) Merge main into #5800 ### 📊 Changes **12 files changed** (+957 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/crash.rs` (+24 -0) 📝 `crates/horizon-client/src/game.rs` (+14 -5) 📝 `crates/horizon-client/src/game/chat.rs` (+13 -0) ➕ `crates/horizon-client/src/game/ram_limit.rs` (+75 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+11 -7) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) 📝 `crates/horizon-client/src/main.rs` (+2 -1) ➕ `crates/horizon-client/src/ram_limit.rs` (+355 -0) 📝 `crates/horizon-threads/Cargo.toml` (+1 -1) 📝 `crates/horizon-threads/src/lib.rs` (+1 -0) ➕ `crates/horizon-threads/src/memory_limit.rs` (+449 -0) 📝 `docs/native-client.md` (+11 -0) </details> ### 📄 Description > 🤖 Opened by 1038april's AI agent (Claude Code, Opus 5.5), not by 1038april personally. ## What and why Part of #5798. The game side of a RAM limit; the launcher's row is in its own pull request. `HORIZON_MEMORY_LIMIT_MB` and `/ramlimit`, `/ramlimit <MB>`, `/ramlimit off` limit the RAM the game holds. With neither set, nothing changes and no thread runs. - **Windows:** a hard working set limit (`SetProcessWorkingSetSizeEx`). The system moves what the game used least out of RAM, so a low limit costs speed instead of failing. - **Slow and faulting hard on Windows, or nearing the limit elsewhere:** far terrain goes off and the render distance in use drops, never the saved option. Both come back when there is room. - **Crash, only as a last resort:** on Windows, no frame for 60 s while faulting hard (the cap is lifted first so the report can be written). Elsewhere, 20 s over the limit with nothing left to give up. These reports don't go to crash telemetry, since the player chose the limit. - `/ramlimit` is answered by the window on any server, joins the chat's command list, and lasts until the game closes. Measured on Windows with a real game teleporting to force new chunks, hidden window, render distance 12, limit set from launch: | Limit | Peak RAM | Result | | --- | --- | --- | | none | 1339 MB | | | 1000 MB | 999 MB | no frames lost, render distance kept | | 500 MB | 500 MB | no frames lost | | 60 MB | 60 MB | choppy, render distance fell to 2 (before the last tuning of when it steps down) | | 20 MB | 20 MB | about 0-8 fps, still running | | 5 MB, 1 MB | at the limit until the crash | froze, then a crash report after about a minute | **For review:** - Memory moved out of RAM can go to the page file. Private bytes stayed around 3 GB, so this limits RAM, not total memory. - Linux and macOS have no such limit. There, chunks are the main thing to give up, and on Windows the game still held about 1250 MB at render distance 4, so a lower limit there would likely end in the last-resort crash. - The page fault thresholds come from this one machine. **Not tested:** Linux and macOS, which I couldn't compile or run here (CI will be the first build); a normal visible window under load, since the runs above used a hidden one; a minimized game at a low limit; a real multiplayer server. ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [x] 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. The window answers `/ramlimit` itself; vanilla's command tree is untouched. ## Other projects' code none ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on KernelOS-PC, against upstream/main at 5edb339a7, 4 min 54 s) | Check | Result | | --- | --- | | Scope | ⚠️ 13 files, +934 −12; 935 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 511 passed (52 s) | | rustfmt | ✅ (8 s) | | clippy | ✅ (34 s) | | tests: horizon-client, horizon-client-render, horizon-threads | ❌ 1614 passed, 1 failed (3 min 14 s) | | doc tests | ✅ 0 passed (3 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The one failure isn't from this change: `loot_table_load_stays_hookable` searches a source file for a newline-delimited `}`, and a Windows checkout has CRLF. `--quick`, so harnesses weren't run. The size is over the guideline; a good part of it is tests. 🤖 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 06:21:45 +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#6506
No description provided.