[PR #7088] [MERGED] perf: read registries.json and the command folders once, off the join frame #7325

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

📋 Pull Request Information

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

Base: main ← Head: perf/join-frame


📝 Commits (1)

  • c38ef83 perf: read registries.json and the command folders once, off the join frame

📊 Changes

2 files changed (+156 additions, -76 deletions)

View changed files

📝 crates/horizon-client/src/game/chat.rs (+136 -72)
📝 crates/horizon-client/src/game/remote.rs (+20 -4)

📄 Description

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

Joining a server (or opening a single-player world, which joins its server thread the same way) parsed registries.json (~3 ms) and, in build_registries, read entity-types.json, five data folders and every timeline file (~2 ms) on the main thread, in the frame that runs the Join click. Those files never change while the game runs. They are now cached per resources root, next to the recipe and loot ids that were already cached that way, and the title screen's "Registries preload" thread (#6952) fills both caches before the first join.

  • remote.rs: builtin_registries(root) keeps one Arc<Builtin> per root. Remote.builtin was already an Arc. A missing or invalid file is not cached, so a repaired install can join again.
  • chat.rs: ResourceIds now holds the entity types, the enchantment, structure, biome and clock ids, and the overworld timelines with their markers. build_registries copies them instead of reading the disk. The fallback when entity-types.json is missing is unchanged.
  • New test: only the overworld clock's timelines count, and a marker can be a bare tick count (hidden from commands) or an object.

A/B: RD 32 join, Mac mini M4 Pro, 3 alternated pairs (tools/pacing_bench.py --scenarios join)

Base is origin/main b82089c77; "new" is the same plus this PR. connect is the control span: the main-thread work of the Join command.

base 1 new 1 base 2 new 2 base 3 new 3 mean base → new
Join frame (ms, frame start to frame start, menu capped at 60 FPS) 27.20 20.21 24.79 23.73 26.65 19.48 26.2 → 21.1
connect work on the main thread (ms) 6.2 3.1 6.2 2.8 5.7 3.1 6.0 → 3.0
Worst frame of the whole join (ms) 27.20 21.28 24.79 23.73 26.65 22.45 26.2 → 22.5
p99.9 (ms) 6.37 4.95 5.33 6.72 5.09 4.67 —

What remains of the Join frame is the 60 FPS menu cap plus ~3 ms (cloning the language table, the chat's command tree, Streaming::new). In-world frames during the join are unchanged; p99.9 varies from run to run on the loaded Mac.

Not fixed here: in every run, the frame just before the Join command is blocked 7–10 ms in queue.submit. A Time Profiler trace shows the main thread waiting on Metal's command-queue lock while a driver thread is in IOGPUCommandQueueSubmitCommandBuffers. That frame happens before the join code runs, so this PR cannot affect it. I couldn't tie it to anything Horizon does.

pr_ready (tools/pr_ready.py --quick on playhorizon, against origin/main at b82089c77, 16 min 44 s)

Check Result
Scope ✅ 2 files, +156 −76
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 611 passed (1 min 8 s)
rustfmt ✅ (14 s)
clippy ✅ (5 min 42 s)
tests: horizon-client ✅ 662 passed (8 min 24 s)
doc tests ✅ 0 passed (3 s)
content root tests ➖ content root untouched
mod API up to date ✅ (53 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 62 affected, to run in CI (--quick): armor_stand_frost, armor_stand_turtle_egg, arrow, arrow_wind_charge, blending, block_removal, block_tint, boat_authority, boat_paddle_reset, boat_submerged, command_exec, composter and 50 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/7088 **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/join-frame` --- ### 📝 Commits (1) - [`c38ef83`](https://github.com/horizon-rust/horizon/commit/c38ef8390760a08ce26ea1d1f651b28ee91ed3e1) perf: read registries.json and the command folders once, off the join frame ### 📊 Changes **2 files changed** (+156 additions, -76 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/chat.rs` (+136 -72) 📝 `crates/horizon-client/src/game/remote.rs` (+20 -4) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Joining a server (or opening a single-player world, which joins its server thread the same way) parsed `registries.json` (~3 ms) and, in `build_registries`, read `entity-types.json`, five data folders and every timeline file (~2 ms) on the main thread, in the frame that runs the Join click. Those files never change while the game runs. They are now cached per resources root, next to the recipe and loot ids that were already cached that way, and the title screen's "Registries preload" thread (#6952) fills both caches before the first join. - `remote.rs`: `builtin_registries(root)` keeps one `Arc<Builtin>` per root. `Remote.builtin` was already an `Arc`. A missing or invalid file is not cached, so a repaired install can join again. - `chat.rs`: `ResourceIds` now holds the entity types, the enchantment, structure, biome and clock ids, and the overworld timelines with their markers. `build_registries` copies them instead of reading the disk. The fallback when `entity-types.json` is missing is unchanged. - New test: only the overworld clock's timelines count, and a marker can be a bare tick count (hidden from commands) or an object. ### A/B: RD 32 join, Mac mini M4 Pro, 3 alternated pairs (`tools/pacing_bench.py --scenarios join`) Base is origin/main b82089c77; "new" is the same plus this PR. `connect` is the `control` span: the main-thread work of the Join command. | | base 1 | new 1 | base 2 | new 2 | base 3 | new 3 | mean base → new | |---|---|---|---|---|---|---|---| | Join frame (ms, frame start to frame start, menu capped at 60 FPS) | 27.20 | 20.21 | 24.79 | 23.73 | 26.65 | 19.48 | **26.2 → 21.1** | | `connect` work on the main thread (ms) | 6.2 | 3.1 | 6.2 | 2.8 | 5.7 | 3.1 | **6.0 → 3.0** | | Worst frame of the whole join (ms) | 27.20 | 21.28 | 24.79 | 23.73 | 26.65 | 22.45 | 26.2 → 22.5 | | p99.9 (ms) | 6.37 | 4.95 | 5.33 | 6.72 | 5.09 | 4.67 | — | What remains of the Join frame is the 60 FPS menu cap plus ~3 ms (cloning the language table, the chat's command tree, `Streaming::new`). In-world frames during the join are unchanged; p99.9 varies from run to run on the loaded Mac. Not fixed here: in every run, the frame just before the Join command is blocked 7–10 ms in `queue.submit`. A Time Profiler trace shows the main thread waiting on Metal's command-queue lock while a driver thread is in `IOGPUCommandQueueSubmitCommandBuffers`. That frame happens before the join code runs, so this PR cannot affect it. I couldn't tie it to anything Horizon does. **pr_ready** (`tools/pr_ready.py --quick` on playhorizon, against origin/main at b82089c77, 16 min 44 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +156 −76 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 611 passed (1 min 8 s) | | rustfmt | ✅ (14 s) | | clippy | ✅ (5 min 42 s) | | tests: horizon-client | ✅ 662 passed (8 min 24 s) | | doc tests | ✅ 0 passed (3 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (53 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 62 affected, to run in CI (--quick): armor_stand_frost, armor_stand_turtle_egg, arrow, arrow_wind_charge, blending, block_removal, block_tint, boat_authority, boat_paddle_reset, boat_submerged, command_exec, composter and 50 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:37:43 +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#7325
No description provided.