[PR #6265] [MERGED] LAN server: keep recipe files as JSON text (−4.2 MB idle) #6753

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/6265
Author: @ludovic111
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: perf/lan-recipe-text


📝 Commits (1)

  • e6ed585 LAN server: keep recipe files as compact JSON text, parse per book entry

📊 Changes

1 file changed (+16 additions, -5 deletions)

View changed files

📝 crates/horizon-client/src/lan/advancements.rs (+16 -5)

📄 Description

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

What

ServerAdvancements (the LAN/dedicated server's recipe book packets) kept every recipe file parsed as serde_json::Value for the server's whole run, only to build recipe book entries when a player joins, unlocks a recipe or asks for a ghost recipe. It now keeps each file as compact JSON text and parses the one an entry needs. Packets are unchanged: same parse, same code, later.

  • Heap (Mac counting-allocator probe): 2,042 recipes as Values 4.60 MB → 0.57 MB as text.
  • First use: parsing all 2,042 recipes takes 1.2 ms: the worst case, a player joining with the full book (initial_recipe_book). One unlock parses one file (µs). No warm-up needed.

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 167.9 −4.2
2 172.0 167.9 −4.1
3 171.6 167.1 −4.5
4 172.8 167.4 −5.4
5 172.5 168.6 −3.9
median 172.1 167.9 −4.2 MB, 5/5

Startup: rounds 1-2 (the host was quiet) Done 1.965/2.007 s → 1.863/1.973 s; rounds 3-5 are unusable (CI load on the host, load average 25, Done 6-15 s for every binary). The change does not touch the start path. MSPT: not measured; the tick path is untouched (only join/unlock packets).

🤖 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/6265 **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/lan-recipe-text` --- ### 📝 Commits (1) - [`e6ed585`](https://github.com/horizon-rust/horizon/commit/e6ed585f5aebbf11ad36ee68028edf8e02c8c35e) LAN server: keep recipe files as compact JSON text, parse per book entry ### 📊 Changes **1 file changed** (+16 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/lan/advancements.rs` (+16 -5) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What `ServerAdvancements` (the LAN/dedicated server's recipe book packets) kept every recipe file parsed as `serde_json::Value` for the server's whole run, only to build recipe book entries when a player joins, unlocks a recipe or asks for a ghost recipe. It now keeps each file as compact JSON text and parses the one an entry needs. Packets are unchanged: same parse, same code, later. - Heap (Mac counting-allocator probe): 2,042 recipes as Values **4.60 MB → 0.57 MB** as text. - First use: parsing all 2,042 recipes takes **1.2 ms**: the worst case, a player joining with the full book (`initial_recipe_book`). One unlock parses one file (µs). No warm-up needed. ## 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 | 167.9 | −4.2 | | 2 | 172.0 | 167.9 | −4.1 | | 3 | 171.6 | 167.1 | −4.5 | | 4 | 172.8 | 167.4 | −5.4 | | 5 | 172.5 | 168.6 | −3.9 | | **median** | **172.1** | **167.9** | **−4.2 MB, 5/5** | Startup: rounds 1-2 (the host was quiet) Done 1.965/2.007 s → 1.863/1.973 s; rounds 3-5 are unusable (CI load on the host, load average 25, Done 6-15 s for every binary). The change does not touch the start path. MSPT: not measured; the tick path is untouched (only join/unlock packets). 🤖 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#6753
No description provided.