[PR #6952] [MERGED] Preload the command registries' caches: Join no longer freezes a 45 ms frame #7224

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

📋 Pull Request Information

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

Base: main ← Head: perf/preload-command-registries


📝 Commits (2)

  • 9ee964b Preload the command registries' resource caches: the Join click's 45 ms frame
  • f9aebd3 Merge remote-tracking branch 'origin/main' into perf/preload-command-registries

📊 Changes

2 files changed (+28 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+2 -0)
📝 crates/horizon-client/src/game/chat.rs (+26 -0)

📄 Description

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

Clicking Join froze one frame for 40–50 ms on an M4 Pro, the only frame over 33 ms when joining a server at render distance 32. The connect step spent 20 ms of it in build_registries, filling caches that are kept afterwards:

  • resource_ids: walks thousands of recipe and loot table files, 7.7 ms
  • block_properties: 6.1 ms
  • parsing command-registries.json: 4.9 ms

(HORIZON_SPIKES laps, first join of the process.) The first single-player world opened paid the same, behind its loading screen.

Change: once the game has started (after the mods, whose structure templates the ids include), a helper thread at behind_server priority fills those three caches. Each cache holds its lock while it builds, so a world opened before the thread is done waits for it, as it did before. A dedicated server is unchanged.

A/B (Mac mini M4 Pro, 1280×720 offscreen, RD 32, tools/pacing_bench.py join scenario: a dedicated server of the same build, then connect, recorded until 5 s after the view is loaded; main ce018133e vs this branch, alternated ×4, GPU lock held):

run main max (ms) this PR max (ms) main frames >33 ms this PR frames >33 ms
1 40.2 23.1 1 0
2 50.1 26.2 1 0
3 43.4 23.2 1 0
4 45.5 22.0 1 0

The other columns don't move (medians: p50 1.16 / 1.16 ms, p99 3.10 / 3.15, 1% low 217 / 226 FPS).

pr_ready (tools/pr_ready.py --quick on playhorizon, against origin/main at 5d65d7b50, 10 min 32 s)

Check Result
Scope ✅ 2 files, +28 −0
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 610 passed (1 min 15 s)
rustfmt ✅ (15 s)
clippy ✅ (3 min 57 s)
tests: horizon-client ✅ 652 passed (4 min 12 s)
doc tests ✅ 0 passed (2 s)
content root tests ➖ content root untouched
mod API up to date ✅ (36 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 63 affected, to run in CI (--quick): armor_stand_frost, armor_stand_turtle_egg, arrow, arrow_wind_charge, blending, block_particles, block_removal, block_tint, boat_authority, boat_paddle_reset, boat_submerged, breaking_model and 51 more
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/6952 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/preload-command-registries` --- ### 📝 Commits (2) - [`9ee964b`](https://github.com/horizon-rust/horizon/commit/9ee964b459e0710bb741a59d659a8656db24c410) Preload the command registries' resource caches: the Join click's 45 ms frame - [`f9aebd3`](https://github.com/horizon-rust/horizon/commit/f9aebd3b3e88cc414077044caa49e88722d7e96c) Merge remote-tracking branch 'origin/main' into perf/preload-command-registries ### 📊 Changes **2 files changed** (+28 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+2 -0) 📝 `crates/horizon-client/src/game/chat.rs` (+26 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Clicking Join froze one frame for 40–50 ms on an M4 Pro, the only frame over 33 ms when joining a server at render distance 32. The `connect` step spent 20 ms of it in `build_registries`, filling caches that are kept afterwards: - `resource_ids`: walks thousands of recipe and loot table files, 7.7 ms - `block_properties`: 6.1 ms - parsing `command-registries.json`: 4.9 ms (HORIZON_SPIKES laps, first join of the process.) The first single-player world opened paid the same, behind its loading screen. **Change:** once the game has started (after the mods, whose structure templates the ids include), a helper thread at `behind_server` priority fills those three caches. Each cache holds its lock while it builds, so a world opened before the thread is done waits for it, as it did before. A dedicated server is unchanged. **A/B** (Mac mini M4 Pro, 1280×720 offscreen, RD 32, `tools/pacing_bench.py` `join` scenario: a dedicated server of the same build, then `connect`, recorded until 5 s after the view is loaded; main ce018133e vs this branch, alternated ×4, GPU lock held): | run | main max (ms) | this PR max (ms) | main frames >33 ms | this PR frames >33 ms | |---|---|---|---|---| | 1 | 40.2 | 23.1 | 1 | 0 | | 2 | 50.1 | 26.2 | 1 | 0 | | 3 | 43.4 | 23.2 | 1 | 0 | | 4 | 45.5 | 22.0 | 1 | 0 | The other columns don't move (medians: p50 1.16 / 1.16 ms, p99 3.10 / 3.15, 1% low 217 / 226 FPS). **pr_ready** (`tools/pr_ready.py --quick` on playhorizon, against origin/main at 5d65d7b50, 10 min 32 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +28 −0 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 610 passed (1 min 15 s) | | rustfmt | ✅ (15 s) | | clippy | ✅ (3 min 57 s) | | tests: horizon-client | ✅ 652 passed (4 min 12 s) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (36 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 63 affected, to run in CI (--quick): armor_stand_frost, armor_stand_turtle_egg, arrow, arrow_wind_charge, blending, block_particles, block_removal, block_tint, boat_authority, boat_paddle_reset, boat_submerged, breaking_model and 51 more | | 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:35:58 +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#7224
No description provided.