[PR #7183] [MERGED] Prepared data file: structure templates in it, texture folders listed from it #7397

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

📋 Pull Request Information

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

Base: main ← Head: perf/prepared-data-structures


📝 Commits (2)

  • eae6fc6 Prepared data file: structure templates in it, texture folders listed from it
  • 6691b00 prepared_files: the find test knows worldgen/structure is held now

📊 Changes

10 files changed (+233 additions, -84 deletions)

View changed files

📝 Cargo.lock (+1 -0)
📝 crates/horizon-client-render/src/atlas_sources.rs (+10 -0)
📝 crates/horizon-client-render/src/fusion.rs (+59 -38)
📝 crates/horizon-client-render/src/hud.rs (+10 -0)
📝 crates/horizon-client-render/src/ui.rs (+51 -30)
📝 crates/horizon-client/src/game/chat.rs (+12 -0)
📝 crates/horizon-core/src/prepared_files.rs (+63 -4)
📝 crates/horizon-optifine/Cargo.toml (+1 -0)
📝 crates/horizon-optifine/src/paths.rs (+12 -0)
📝 crates/horizon-world/src/worldgen/structure.rs (+14 -12)

📄 Description

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

This is the last step of the prepared data file series (#6893, #6976, #7055, #7072). It moves structure templates into horizon-data.bin, and the game now lists texture folders from the file instead of walking them on disk about ten times. On slow disks and on Windows with Defender, each file open costs a scan, so fewer opens means a faster start.

What changes

  • horizon_core::prepared_files: worldgen/structure joins the held folders. VERSION is now 2, so a version 1 file is refused and rewritten on the next start. New files_under(dir) returns the files below a held folder (None when the folder isn't held, so the caller walks the disk as before).
  • Structure templates (worldgen/structure.rs) are read through prepared_files::read.
  • The callers that used to walk texture folders now list them with files_under: atlas sources, the HUD sprite walk, fusion .mcmeta, GUI sprite metadata (ui.rs), OptiFine folder walks (horizon-optifine gains a horizon-core dependency), and the chat ids_in lookup.
  • Mod content and resource packs keep their disk paths. Only the prepared root's folders come from the file.

Measured

Linux, playhorizon, strace -f -e trace=open,openat from launch to world.view_full, two alternated rounds, same prepared root (copied, so the second binary writes its own v2 file):

opens under the root textures structure templates all opens
main (#7072) round 1 4,737 1,764 683 6,940
this PR round 1 2,512 261 0 4,640
main round 2 4,755 1,764 690 6,844
this PR round 2 2,512 261 0 4,566

Since the series started, opens under the root went from 40,282 on main to 2,512. The biggest folder left is assets/minecraft/sounds (736 opens), which streams audio on demand. horizon-data.bin grows from 18.4 MB to 22.8 MB.

Wall times on that machine (llvmpipe, shared CPU) swing by seconds between runs, so they show nothing either way. The win is on Windows/Defender and slow disks, which I could not measure here.

Tested

  • horizon-core (files_under_lists_a_folder_from_the_file, the find test knows worldgen/structure is held now), horizon-optifine (134), and the render, world and client tests that touch these paths. All pass on Linux and macOS.
  • cargo clippy -p horizon-client -p horizon-client-lib --lib --bins --tests -- -D warnings passes.
  • The game reaches world.view_full in both rounds, with structures generating from the file.

🤖 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/7183 **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/prepared-data-structures` --- ### 📝 Commits (2) - [`eae6fc6`](https://github.com/horizon-rust/horizon/commit/eae6fc63662b73856f67ebf2d8635ac0ffe89cb4) Prepared data file: structure templates in it, texture folders listed from it - [`6691b00`](https://github.com/horizon-rust/horizon/commit/6691b009ad67b08ce9e3d8e034f45514fa1654d9) prepared_files: the find test knows worldgen/structure is held now ### 📊 Changes **10 files changed** (+233 additions, -84 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+1 -0) 📝 `crates/horizon-client-render/src/atlas_sources.rs` (+10 -0) 📝 `crates/horizon-client-render/src/fusion.rs` (+59 -38) 📝 `crates/horizon-client-render/src/hud.rs` (+10 -0) 📝 `crates/horizon-client-render/src/ui.rs` (+51 -30) 📝 `crates/horizon-client/src/game/chat.rs` (+12 -0) 📝 `crates/horizon-core/src/prepared_files.rs` (+63 -4) 📝 `crates/horizon-optifine/Cargo.toml` (+1 -0) 📝 `crates/horizon-optifine/src/paths.rs` (+12 -0) 📝 `crates/horizon-world/src/worldgen/structure.rs` (+14 -12) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. This is the last step of the prepared data file series (#6893, #6976, #7055, #7072). It moves structure templates into `horizon-data.bin`, and the game now lists texture folders from the file instead of walking them on disk about ten times. On slow disks and on Windows with Defender, each file open costs a scan, so fewer opens means a faster start. ## What changes - `horizon_core::prepared_files`: `worldgen/structure` joins the held folders. `VERSION` is now 2, so a version 1 file is refused and rewritten on the next start. New `files_under(dir)` returns the files below a held folder (`None` when the folder isn't held, so the caller walks the disk as before). - Structure templates (`worldgen/structure.rs`) are read through `prepared_files::read`. - The callers that used to walk texture folders now list them with `files_under`: atlas sources, the HUD sprite walk, fusion `.mcmeta`, GUI sprite metadata (`ui.rs`), OptiFine folder walks (`horizon-optifine` gains a `horizon-core` dependency), and the chat `ids_in` lookup. - Mod content and resource packs keep their disk paths. Only the prepared root's folders come from the file. ## Measured Linux, playhorizon, `strace -f -e trace=open,openat` from launch to `world.view_full`, two alternated rounds, same prepared root (copied, so the second binary writes its own v2 file): | | opens under the root | textures | structure templates | all opens | |---|---|---|---|---| | main (#7072) round 1 | 4,737 | 1,764 | 683 | 6,940 | | this PR round 1 | **2,512** | 261 | 0 | 4,640 | | main round 2 | 4,755 | 1,764 | 690 | 6,844 | | this PR round 2 | **2,512** | 261 | 0 | 4,566 | Since the series started, opens under the root went from 40,282 on main to 2,512. The biggest folder left is `assets/minecraft/sounds` (736 opens), which streams audio on demand. `horizon-data.bin` grows from 18.4 MB to 22.8 MB. Wall times on that machine (llvmpipe, shared CPU) swing by seconds between runs, so they show nothing either way. The win is on Windows/Defender and slow disks, which I could not measure here. ## Tested - `horizon-core` (`files_under_lists_a_folder_from_the_file`, the `find` test knows `worldgen/structure` is held now), `horizon-optifine` (134), and the render, world and client tests that touch these paths. All pass on Linux and macOS. - `cargo clippy -p horizon-client -p horizon-client-lib --lib --bins --tests -- -D warnings` passes. - The game reaches `world.view_full` in both rounds, with structures generating from the file. 🤖 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:38:57 +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#7397
No description provided.