[PR #5765] [MERGED] horizon-server: [engine] low_memory turns transparent huge pages off #6483

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

📋 Pull Request Information

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

Base: main ← Head: feat/server-low-memory


📝 Commits (1)

  • 8e69245 horizon-server: [engine] low_memory turns transparent huge pages off

📊 Changes

5 files changed (+63 additions, -3 deletions)

View changed files

📝 crates/horizon-server/src/config.rs (+5 -0)
📝 crates/horizon-server/src/engine.rs (+37 -2)
📝 crates/horizon-server/src/supervisor.rs (+1 -1)
📝 docs/api/server-reference.md (+1 -0)
📝 docs/hosting.md (+19 -0)

📄 Description

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

A new server.toml setting, [engine] low_memory = false. When it is true, horizon-server starts the headless game with MIMALLOC_ALLOW_THP=0. mimalloc then stops backing the game's memory with transparent huge pages. On Linux, many of those 2 MB pages are only partly used: they cost memory but make the tick a little faster. Off by default, so the default stays the fast one.

  • config.rs: the field (default false), the template line and the rendered key. docs/api/server-reference.md is regenerated.
  • engine.rs: spawn builds its command in command(), which sets the variable when low_memory is on. The supervisor passes config.engine.low_memory, read again at every (re)start.
  • docs/hosting.md: the setting in the [engine] example, and a "Less memory: low_memory" section with the numbers below. It also explains that MIMALLOC_ALLOW_THP=0 works without the setting, and that the setting does nothing on macOS and Windows.
  • The launcher's hosting UI writes server.toml through horizon-server config set, so the setting works from there without a launcher change. A toggle can come later if hosts ask for it.

Measurement

playhorizon (4-core EPYC VPS, CPUs 0-3 exclusive), release builds, 20 mixed bots (server_bench.py). Main b6ac0602d, with and without huge pages for mimalloc. That change was first tested as arena_eager_commit = 0, which gives the same memory as MIMALLOC_ALLOW_THP=0: both remove all 84 MB of AnonHugePages.

Default low_memory = true
RSS idle after start (3 rounds) 314 / 311 / 292 MB 247 / 246 / 247 MB
RSS at 20 players (mean) ~1180 MB ~980 MB
MSPT at 20 players (5 rounds) 26.41 / 27.12 / 27.20 / 27.37 / 27.13 26.74 / 27.61 / 27.45 / 27.75 / 27.18 (median +1.2 %)
Start 2.03-2.11 s 2.13-2.23 s

Checks

  • New unit test low_memory_turns_huge_pages_off_for_the_game: the game's command has MIMALLOC_ALLOW_THP=0 with the setting on, and no such variable with it off.
    pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at 3bc251ea5, 2 min 18 s)
Check Result
Scope ✅ 5 files, +63 −3
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 511 passed (1 min 10 s)
rustfmt ✅ (5 s)
clippy ✅ (51 s)
tests: horizon-server ✅ 98 passed (10 s)
doc tests ➖ no library touched
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 ➖ 2 affected, to run in CI (--quick): lan_integration, management_protocol
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/5765 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/server-low-memory` --- ### 📝 Commits (1) - [`8e69245`](https://github.com/horizon-rust/horizon/commit/8e692458eb7f753acc5d719deb1afcba65d38a8a) horizon-server: [engine] low_memory turns transparent huge pages off ### 📊 Changes **5 files changed** (+63 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-server/src/config.rs` (+5 -0) 📝 `crates/horizon-server/src/engine.rs` (+37 -2) 📝 `crates/horizon-server/src/supervisor.rs` (+1 -1) 📝 `docs/api/server-reference.md` (+1 -0) 📝 `docs/hosting.md` (+19 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. A new `server.toml` setting, `[engine] low_memory = false`. When it is `true`, `horizon-server` starts the headless game with `MIMALLOC_ALLOW_THP=0`. mimalloc then stops backing the game's memory with transparent huge pages. On Linux, many of those 2 MB pages are only partly used: they cost memory but make the tick a little faster. Off by default, so the default stays the fast one. - `config.rs`: the field (default `false`), the template line and the rendered key. `docs/api/server-reference.md` is regenerated. - `engine.rs`: `spawn` builds its command in `command()`, which sets the variable when `low_memory` is on. The supervisor passes `config.engine.low_memory`, read again at every (re)start. - `docs/hosting.md`: the setting in the `[engine]` example, and a "Less memory: `low_memory`" section with the numbers below. It also explains that `MIMALLOC_ALLOW_THP=0` works without the setting, and that the setting does nothing on macOS and Windows. - The launcher's hosting UI writes `server.toml` through `horizon-server config set`, so the setting works from there without a launcher change. A toggle can come later if hosts ask for it. ### Measurement playhorizon (4-core EPYC VPS, CPUs 0-3 exclusive), release builds, 20 mixed bots (`server_bench.py`). Main b6ac0602d, with and without huge pages for mimalloc. That change was first tested as `arena_eager_commit = 0`, which gives the same memory as `MIMALLOC_ALLOW_THP=0`: both remove all 84 MB of `AnonHugePages`. | | Default | `low_memory = true` | |---|---|---| | RSS idle after start (3 rounds) | 314 / 311 / 292 MB | 247 / 246 / 247 MB | | RSS at 20 players (mean) | ~1180 MB | ~980 MB | | MSPT at 20 players (5 rounds) | 26.41 / 27.12 / 27.20 / 27.37 / 27.13 | 26.74 / 27.61 / 27.45 / 27.75 / 27.18 (median +1.2 %) | | Start | 2.03-2.11 s | 2.13-2.23 s | ### Checks - New unit test `low_memory_turns_huge_pages_off_for_the_game`: the game's command has `MIMALLOC_ALLOW_THP=0` with the setting on, and no such variable with it off. **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at 3bc251ea5, 2 min 18 s) | Check | Result | | --- | --- | | Scope | ✅ 5 files, +63 −3 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 511 passed (1 min 10 s) | | rustfmt | ✅ (5 s) | | clippy | ✅ (51 s) | | tests: horizon-server | ✅ 98 passed (10 s) | | doc tests | ➖ no library touched | | 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 | ➖ 2 affected, to run in CI (--quick): lan_integration, management_protocol | | 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 06:21:21 +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#6483
No description provided.