[PR #756] [MERGED] Content mods: keep the built content root for later starts #2782

Closed
opened 2026-11-02 15:59:01 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/756
Author: @ludovic111
Created: 10/17/2026
Status: ✅ Merged
Merged: 10/18/2026
Merged by: @ludovic111

Base: main ← Head: perf/content-root-cache


📝 Commits (1)

  • 24fd51b Content mods: keep the built content root for later starts

📊 Changes

3 files changed (+102 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/mod_content.rs (+60 -0)
📝 crates/horizon-client/src/mod_content_tests.rs (+35 -0)
📝 crates/horizon-mods/src/content.rs (+7 -0)

📄 Description

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

What

docs/modpacks.md says the content-mod overlay "is cached like the resource-pack overlay and rebuilt when a mod file changes". On main it isn't: mod_content::resource_root rebuilt .horizon-cache/mod-content on every start that had mods. For ATM10's 40-42 carried mods, that rebuild takes about 25 s of the title time and briefly holds more than 3 GB of footprint.

Now resource_root writes horizon-mod-content.stamp next to the root it built, and returns early when the stamp still matches. The stamp is a SHA-256 over:

  • the running executable (path, size, mtime), so a new build or release rebuilds;
  • horizon-resources.json and the metadata of every base table the build reads;
  • each mod's id and the metadata (path, size, mtime) of each of its files, or of its .hmod.

Adding, removing or editing a mod (or an update of Horizon) rebuilds. The stamp is written only after a build succeeds.

Numbers

tools/perf_bench.py --port-work (and --warm from #755 for later starts), RD 8, one game each. The same 40 ATM10 mods on both games (the 42 without Regions Unexplored and MO Structures, whose libraries are CurseForge-only). Mac mini M4 Pro with load average 80-125, so treat the spread as wide:

run title / world s RSS steady / peak MB footprint steady / peak MB
main (every start rebuilds) 81.1 / 102.8 4,008 / 4,164 2,368 / 2,554
this stack, first start 105.2 / 128.8 3,795 / 3,993 2,306 / 2,560
this stack, later starts 21.6 / 33.7 2,629 / 2,935 2,445 / 2,731
NeoForge 21.1.259 + the same 40 mods, -Xmx2G 53.2 / 119.9 3,099 / 3,203 3,304 / 3,381

"This stack" is this PR with #753, #754 and the worldgen PR merged together. The first start is slower than main's here only because the machine's load varied (88-125 against 79-97). On later starts the game reaches the title 3.8x sooner than on main. Against NeoForge with the same mods, later starts are -15 % RSS and -26 % footprint, with the title 2.5x and the world 3.6x sooner.

Checks

  • cargo fmt --all -- --check, cargo clippy -p horizon-client -p horizon-mods --all-targets -- -D warnings: clean.
  • cargo test -p horizon-client mod_content: passes, including the new content_root_is_reused_until_a_mod_changes. A sentinel file in the built root survives a second call and is gone after a mod file's mtime changes.
  • Parity: tools/parity.py --changed origin/main on this work merged together (#753, #754, #755, #756, #764 and #762): 298 harnesses selected, all pass. Three failed on the first run for reasons outside this code, and their reruns passed: datafix lost its connection while generating 1.8.9 sample worlds (load average 140), the Java oracle timed out in decoration, and another session's pkill killed a 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/756 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/17/2026 **Status:** ✅ Merged **Merged:** 10/18/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/content-root-cache` --- ### 📝 Commits (1) - [`24fd51b`](https://github.com/horizon-rust/horizon/commit/24fd51b186b850b30e12797a5e13767189eb75c7) Content mods: keep the built content root for later starts ### 📊 Changes **3 files changed** (+102 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/mod_content.rs` (+60 -0) 📝 `crates/horizon-client/src/mod_content_tests.rs` (+35 -0) 📝 `crates/horizon-mods/src/content.rs` (+7 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What docs/modpacks.md says the content-mod overlay "is cached like the resource-pack overlay and rebuilt when a mod file changes". On main it isn't: `mod_content::resource_root` rebuilt `.horizon-cache/mod-content` on every start that had mods. For ATM10's 40-42 carried mods, that rebuild takes about 25 s of the title time and briefly holds more than 3 GB of footprint. Now `resource_root` writes `horizon-mod-content.stamp` next to the root it built, and returns early when the stamp still matches. The stamp is a SHA-256 over: - the running executable (path, size, mtime), so a new build or release rebuilds; - `horizon-resources.json` and the metadata of every base table the build reads; - each mod's id and the metadata (path, size, mtime) of each of its files, or of its `.hmod`. Adding, removing or editing a mod (or an update of Horizon) rebuilds. The stamp is written only after a build succeeds. ## Numbers `tools/perf_bench.py --port-work` (and `--warm` from #755 for later starts), RD 8, one game each. The same 40 ATM10 mods on both games (the 42 without Regions Unexplored and MO Structures, whose libraries are CurseForge-only). Mac mini M4 Pro with load average 80-125, so treat the spread as wide: | run | title / world s | RSS steady / peak MB | footprint steady / peak MB | |---|---|---|---| | main (every start rebuilds) | 81.1 / 102.8 | 4,008 / 4,164 | 2,368 / 2,554 | | this stack, first start | 105.2 / 128.8 | 3,795 / 3,993 | 2,306 / 2,560 | | **this stack, later starts** | **21.6 / 33.7** | **2,629 / 2,935** | 2,445 / 2,731 | | NeoForge 21.1.259 + the same 40 mods, `-Xmx2G` | 53.2 / 119.9 | 3,099 / 3,203 | 3,304 / 3,381 | "This stack" is this PR with #753, #754 and the worldgen PR merged together. The first start is slower than main's here only because the machine's load varied (88-125 against 79-97). On later starts the game reaches the title 3.8x sooner than on main. Against NeoForge with the same mods, later starts are -15 % RSS and -26 % footprint, with the title 2.5x and the world 3.6x sooner. ## Checks - `cargo fmt --all -- --check`, `cargo clippy -p horizon-client -p horizon-mods --all-targets -- -D warnings`: clean. - `cargo test -p horizon-client mod_content`: passes, including the new `content_root_is_reused_until_a_mod_changes`. A sentinel file in the built root survives a second call and is gone after a mod file's mtime changes. - Parity: `tools/parity.py --changed origin/main` on this work merged together (#753, #754, #755, #756, #764 and #762): 298 harnesses selected, **all pass**. Three failed on the first run for reasons outside this code, and their reruns passed: datafix lost its connection while generating 1.8.9 sample worlds (load average 140), the Java oracle timed out in decoration, and another session's `pkill` killed a 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-02 15:59:01 +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#2782
No description provided.