[PR #6695] [MERGED] Recipes: the start reads the recipe folder once, not once per table #7038

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

📋 Pull Request Information

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

Base: main ← Head: perf/recipes-read-once


📝 Commits (2)

  • bf1fe43 Recipes: the start reads the recipe folder once, not once per table
  • 0bb31c7 Recipes: drop the imports the shared folder read left unused

📊 Changes

8 files changed (+213 additions, -91 deletions)

View changed files

📝 crates/horizon-client-render/src/brewing.rs (+24 -18)
➕ crates/horizon-client-render/src/json_folder.rs (+154 -0)
📝 crates/horizon-client-render/src/lib.rs (+1 -0)
📝 crates/horizon-client/src/client_lib.rs (+8 -8)
📝 crates/horizon-client/src/crafting.rs (+6 -48)
📝 crates/horizon-client/src/game.rs (+6 -0)
📝 crates/horizon-client/src/recipe_book.rs (+7 -8)
📝 crates/horizon-client/src/stations.rs (+7 -9)

📄 Description

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

Part of #1961 (loose resource files at start: Defender scans each one on Windows, and each costs a seek on a hard disk).

Four tables built from the recipe folder each listed and read every file under data/minecraft/recipe again: the crafting tables, the stations, the recipe book and brewing. A start to the title opened each recipe file 7 to 8 times: 14,581 opens for 2,043 files, out of 38,792 opens under the prepared folder in all (strace, Linux).

  • json_folder::read(dir) lists a folder and reads its .json files once. Any reader shares those bytes while one of them holds the folder, and nothing is kept once the last lets go, so no RAM stays after the load. It shares bytes rather than parsed values, because a Value is ~10× its JSON's size (lazy_json).
  • The rest loader holds data/minecraft/recipe across the recipe tables and the stations, and so does /reload. Each table still parses its own copy, in the same order, with the same load conditions and the same errors: crafting still fails on a read error, warns on a file that doesn't parse, and parses only after a pack's file has replaced it.
  • Brewing loaded alone (a server join) still reads only recipe/brewing. crafting::recipe_files moved into json_folder::list, unchanged.

Measured (strace open counts and the rest loader's steps): to follow in a comment, from the playhorizon run.

🤖 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/6695 **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/recipes-read-once` --- ### 📝 Commits (2) - [`bf1fe43`](https://github.com/horizon-rust/horizon/commit/bf1fe4344d6f13f0629e3ecdd09df5d9f101da46) Recipes: the start reads the recipe folder once, not once per table - [`0bb31c7`](https://github.com/horizon-rust/horizon/commit/0bb31c7d423c54cbbaa1aeeb70ee7956cadb639f) Recipes: drop the imports the shared folder read left unused ### 📊 Changes **8 files changed** (+213 additions, -91 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/brewing.rs` (+24 -18) ➕ `crates/horizon-client-render/src/json_folder.rs` (+154 -0) 📝 `crates/horizon-client-render/src/lib.rs` (+1 -0) 📝 `crates/horizon-client/src/client_lib.rs` (+8 -8) 📝 `crates/horizon-client/src/crafting.rs` (+6 -48) 📝 `crates/horizon-client/src/game.rs` (+6 -0) 📝 `crates/horizon-client/src/recipe_book.rs` (+7 -8) 📝 `crates/horizon-client/src/stations.rs` (+7 -9) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Part of #1961 (loose resource files at start: Defender scans each one on Windows, and each costs a seek on a hard disk). Four tables built from the recipe folder each listed and read every file under `data/minecraft/recipe` again: the crafting tables, the stations, the recipe book and brewing. A start to the title opened each recipe file 7 to 8 times: 14,581 opens for 2,043 files, out of 38,792 opens under the prepared folder in all (strace, Linux). - `json_folder::read(dir)` lists a folder and reads its `.json` files once. Any reader shares those bytes while one of them holds the folder, and nothing is kept once the last lets go, so no RAM stays after the load. It shares bytes rather than parsed values, because a `Value` is ~10× its JSON's size (`lazy_json`). - The rest loader holds `data/minecraft/recipe` across the recipe tables and the stations, and so does `/reload`. Each table still parses its own copy, in the same order, with the same load conditions and the same errors: crafting still fails on a read error, warns on a file that doesn't parse, and parses only after a pack's file has replaced it. - Brewing loaded alone (a server join) still reads only `recipe/brewing`. `crafting::recipe_files` moved into `json_folder::list`, unchanged. Measured (strace open counts and the rest loader's steps): to follow in a comment, from the playhorizon run. 🤖 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:32:35 +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#7038
No description provided.