[PR #6266] [MERGED] Commands: cache the registries' part of the export, not the export (−3.1 MB idle) #6755

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

📋 Pull Request Information

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

Base: main ← Head: perf/command-export-extract


📝 Commits (1)

  • 7e422bd Commands: cache what the registries take from the export, not the export

📊 Changes

2 files changed (+70 additions, -14 deletions)

View changed files

📝 crates/horizon-client-core/src/registries.rs (+42 -0)
📝 crates/horizon-client/src/game/chat.rs (+28 -14)

📄 Description

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

What

command_export cached the parsed command-registries.json (a serde_json::Value) for the whole run, though Registries::fill_from_export takes only part of it. It now caches Registries::from_export (exactly the fields fill_from_export fills), and build_registries fills from it with fill_from_exported (same rules: a field the game left empty, a registry it did not list). A dedicated server opens its world once, so it keeps nothing; the client keeps the cache, so reopening a world still skips the ~15 ms parse.

  • Heap (Mac counting-allocator probe): export Value 4.24 MB, extracted part 2.15 MB.
  • Test command_exports_are_read_once_per_folder covers the cache and the dedicated (not kept) read.

A/B

Bench: playhorizon (CPUs 0-3, remote.sh --exclusive), fast profile, dedicated server, new world (seed 12345), MIMALLOC_ALLOW_THP=0, anonymous memory (smaps_rollup) 32 s after Done, 5 rounds alternated base → lan → cmd → items. Base = main c86e861455.

round base anon (MB) this PR (MB) direction
1 172.1 165.4 −6.7
2 172.0 169.0 −3.0
3 171.6 169.6 −2.0
4 172.8 170.2 −2.6
5 172.5 165.2 −7.3
median 172.1 169.0 −3.1 MB, 5/5

Startup: rounds 1-2 (quiet host) Done 1.965/2.007 s → 2.000/2.622 s (round 2 already hit the CI load that made rounds 3-5 unusable: 6-15 s for every binary); the parse itself is unchanged and runs once. MSPT: not measured; nothing on the tick path.

🤖 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/6266 **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:** `perf/command-export-extract` --- ### 📝 Commits (1) - [`7e422bd`](https://github.com/horizon-rust/horizon/commit/7e422bd881369a19bd8c4802adfa39e441ddde2f) Commands: cache what the registries take from the export, not the export ### 📊 Changes **2 files changed** (+70 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-core/src/registries.rs` (+42 -0) 📝 `crates/horizon-client/src/game/chat.rs` (+28 -14) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What `command_export` cached the parsed `command-registries.json` (a `serde_json::Value`) for the whole run, though `Registries::fill_from_export` takes only part of it. It now caches `Registries::from_export` (exactly the fields `fill_from_export` fills), and `build_registries` fills from it with `fill_from_exported` (same rules: a field the game left empty, a registry it did not list). A dedicated server opens its world once, so it keeps nothing; the client keeps the cache, so reopening a world still skips the ~15 ms parse. - Heap (Mac counting-allocator probe): export Value **4.24 MB**, extracted part **2.15 MB**. - Test `command_exports_are_read_once_per_folder` covers the cache and the dedicated (not kept) read. ## A/B Bench: playhorizon (CPUs 0-3, `remote.sh --exclusive`), `fast` profile, dedicated server, new world (seed 12345), `MIMALLOC_ALLOW_THP=0`, anonymous memory (`smaps_rollup`) 32 s after `Done`, 5 rounds alternated base → lan → cmd → items. Base = main c86e861455. | round | base anon (MB) | this PR (MB) | direction | |---|---|---|---| | 1 | 172.1 | 165.4 | −6.7 | | 2 | 172.0 | 169.0 | −3.0 | | 3 | 171.6 | 169.6 | −2.0 | | 4 | 172.8 | 170.2 | −2.6 | | 5 | 172.5 | 165.2 | −7.3 | | **median** | **172.1** | **169.0** | **−3.1 MB, 5/5** | Startup: rounds 1-2 (quiet host) Done 1.965/2.007 s → 2.000/2.622 s (round 2 already hit the CI load that made rounds 3-5 unusable: 6-15 s for every binary); the parse itself is unchanged and runs once. MSPT: not measured; nothing on the tick path. 🤖 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:26:09 +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#6755
No description provided.