[PR #680] [MERGED] Content mods' memory: measure the footprint, drop the registry's second copy #2725

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

📋 Pull Request Information

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

Base: main ← Head: perf/mod-content-memory


📝 Commits (5)

  • f48a54d Block state ids past 16 bits
  • 4d1596f Load ATM10's 42 carried mods: room past 8,192 textures and tags
  • ed9a25a Measure where content mods' memory goes; drop the registry's second copy
  • a60519e Merge origin/main into feat/wide-block-states
  • eda6e4b Merge feat/wide-block-states (with origin/main) into perf/mod-content-memory

📊 Changes

51 files changed (+673 additions, -235 deletions)

View changed files

📝 crates/horizon-client/examples/lan_flat.rs (+1 -6)
📝 crates/horizon-client/examples/light_parity.rs (+3 -3)
📝 crates/horizon-client/examples/random_tick_eligibility_bench.rs (+4 -4)
➕ crates/horizon-client/examples/resource_memory.rs (+165 -0)
📝 crates/horizon-client/examples/save_batch_bench.rs (+2 -2)
📝 crates/horizon-client/examples/save_parity.rs (+2 -2)
📝 crates/horizon-client/examples/section_mesh_fixture.rs (+1 -1)
📝 crates/horizon-client/src/assets.rs (+3 -0)
📝 crates/horizon-client/src/chunk.rs (+38 -24)
📝 crates/horizon-client/src/chunk_map.rs (+1 -1)
📝 crates/horizon-client/src/crafting.rs (+9 -1)
📝 crates/horizon-client/src/flatgen.rs (+2 -2)
📝 crates/horizon-client/src/game.rs (+1 -1)
📝 crates/horizon-client/src/game/commands.rs (+4 -7)
📝 crates/horizon-client/src/game/creaking.rs (+1 -1)
📝 crates/horizon-client/src/game/lan.rs (+2 -2)
📝 crates/horizon-client/src/game/natural_spawning.rs (+1 -1)
📝 crates/horizon-client/src/game/remote.rs (+28 -4)
📝 crates/horizon-client/src/game/sculk.rs (+8 -11)
📝 crates/horizon-client/src/gfx.rs (+9 -1)

...and 31 more files

📄 Description

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

Stacked on #674 (it needs the wide state ids to load ATM10's 42 mods). Merge #674 first.

What the "+1.1 GB with mods" was

Mostly the measurement. On macOS ps RSS counts pages the allocator has freed and marked reusable. The content tables are parsed whole at startup and freed, so RSS stays high afterwards. perf_bench.py now also samples the physical footprint (footprint -f bytes, what the OS charges the process) every 2 s on macOS, reports memory.footprint_{steady,peak}_mb, and prints them in --table.

RD 8, the same six mods as in docs/modpacks.md (Cloud Glass, Factory Blocks, Glassential, Macaw's Fences, Paths, Trapdoors). One or two games per row. The Mac mini was shared and very busy: load average 90-138 on 14 threads.

game RSS steady MB footprint steady MB
Horizon 1,598-1,636 1,277-1,295
Horizon + 6 mods 2,996-3,052 1,736-1,869

The six mods cost about 0.5 GB of footprint. ATM10's 42 mods (193,762 states, #674) take the game to 7.7 GB RSS but 3.9 GB footprint.

I couldn't rerun NeoForge in this session: its oracle install was cleaned up, and its jars and deps would have had to be fetched again. The doc's NeoForge + 6 mods row from earlier today, same machine, is 2,325 MB steady RSS. Java's heap pages are dirty, so its RSS is close to its footprint, but a footprint run of NeoForge is the comparison that's still owed.

Where it goes, per loader

examples/resource_memory.rs reports, after each resource loader in the game's start order: the live heap (a counting allocator), the step's peak, RSS, and at the end the footprint. Live heap:

loader vanilla MB ATM10 42 mods MB
block registry 24 125
assets (registry, models, sprites: 153 MB of pixels for 9,790 layers) 94 657
block facts and behaviours +29 +75
items, recipes +14 +82
light, mesh, collision, motion +24 +53
worldgen +79 +182
live / footprint 240 / 551 1,049 / 2,724

Cut in this PR

BlockRegistry kept every state twice: once in states, and again as the key of a BTreeMap<BlockState, BlockStateId>. Ids are now indexed by a 64-bit hash of the state and checked against states, with a fallback map for hash collisions (empty for vanilla).

Probe, alternating base/new runs:

vanilla ATM10 42 mods
live heap -22 MB -124 MB
footprint -30 MB -140 to -175 MB

In game with the six mods: about -50 MB RSS. The footprint change is within the noise.

What's left (documented in docs/modpacks.md)

The startup peak. Each loader parses its per-state tables whole, as JSON trees or as NBT trees. For ATM10 the NBT trees are 300-600 MB each (block-properties.nbt, the collision, support, occlusion and movement tables). Worldgen loading peaks at 3.9 GB live, and the footprint stays near that peak. Typed, streaming readers for those tables are the next cut. They touch horizon-world's worldgen and collision loaders.

Checks

  • cargo fmt; cargo clippy -p horizon-client -p horizon-world --all-targets -D warnings.
  • cargo test -p horizon-world: all pass.
  • Local parity: to follow. registry.rs is read by nearly every harness, so this run is as long as #674's.

🤖 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/680 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/17/2026 **Status:** ✅ Merged **Merged:** 10/17/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/mod-content-memory` --- ### 📝 Commits (5) - [`f48a54d`](https://github.com/horizon-rust/horizon/commit/f48a54da095686cdf5f1088e13e0f5731db0f66e) Block state ids past 16 bits - [`4d1596f`](https://github.com/horizon-rust/horizon/commit/4d1596fe3b903d4f2ca35ad8aac097f571c5f81b) Load ATM10's 42 carried mods: room past 8,192 textures and tags - [`ed9a25a`](https://github.com/horizon-rust/horizon/commit/ed9a25ad49b0ac00adf864cf348d7317ca0f2d57) Measure where content mods' memory goes; drop the registry's second copy - [`a60519e`](https://github.com/horizon-rust/horizon/commit/a60519eb638aff757e2de8f1217aa3a18b5d52a1) Merge origin/main into feat/wide-block-states - [`eda6e4b`](https://github.com/horizon-rust/horizon/commit/eda6e4b510793037a08e66d2f1b89876d7a98664) Merge feat/wide-block-states (with origin/main) into perf/mod-content-memory ### 📊 Changes **51 files changed** (+673 additions, -235 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/lan_flat.rs` (+1 -6) 📝 `crates/horizon-client/examples/light_parity.rs` (+3 -3) 📝 `crates/horizon-client/examples/random_tick_eligibility_bench.rs` (+4 -4) ➕ `crates/horizon-client/examples/resource_memory.rs` (+165 -0) 📝 `crates/horizon-client/examples/save_batch_bench.rs` (+2 -2) 📝 `crates/horizon-client/examples/save_parity.rs` (+2 -2) 📝 `crates/horizon-client/examples/section_mesh_fixture.rs` (+1 -1) 📝 `crates/horizon-client/src/assets.rs` (+3 -0) 📝 `crates/horizon-client/src/chunk.rs` (+38 -24) 📝 `crates/horizon-client/src/chunk_map.rs` (+1 -1) 📝 `crates/horizon-client/src/crafting.rs` (+9 -1) 📝 `crates/horizon-client/src/flatgen.rs` (+2 -2) 📝 `crates/horizon-client/src/game.rs` (+1 -1) 📝 `crates/horizon-client/src/game/commands.rs` (+4 -7) 📝 `crates/horizon-client/src/game/creaking.rs` (+1 -1) 📝 `crates/horizon-client/src/game/lan.rs` (+2 -2) 📝 `crates/horizon-client/src/game/natural_spawning.rs` (+1 -1) 📝 `crates/horizon-client/src/game/remote.rs` (+28 -4) 📝 `crates/horizon-client/src/game/sculk.rs` (+8 -11) 📝 `crates/horizon-client/src/gfx.rs` (+9 -1) _...and 31 more files_ </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Stacked on #674 (it needs the wide state ids to load ATM10's 42 mods). Merge #674 first. ## What the "+1.1 GB with mods" was Mostly the measurement. On macOS `ps` RSS counts pages the allocator has freed and marked reusable. The content tables are parsed whole at startup and freed, so RSS stays high afterwards. `perf_bench.py` now also samples the **physical footprint** (`footprint -f bytes`, what the OS charges the process) every 2 s on macOS, reports `memory.footprint_{steady,peak}_mb`, and prints them in `--table`. RD 8, the same six mods as in docs/modpacks.md (Cloud Glass, Factory Blocks, Glassential, Macaw's Fences, Paths, Trapdoors). One or two games per row. The Mac mini was shared and very busy: load average 90-138 on 14 threads. | game | RSS steady MB | footprint steady MB | |---|---:|---:| | Horizon | 1,598-1,636 | 1,277-1,295 | | Horizon + 6 mods | 2,996-3,052 | 1,736-1,869 | The six mods cost about **0.5 GB of footprint**. ATM10's 42 mods (193,762 states, #674) take the game to 7.7 GB RSS but 3.9 GB footprint. I couldn't rerun NeoForge in this session: its oracle install was cleaned up, and its jars and deps would have had to be fetched again. The doc's NeoForge + 6 mods row from earlier today, same machine, is 2,325 MB steady RSS. Java's heap pages are dirty, so its RSS is close to its footprint, but a footprint run of NeoForge is the comparison that's still owed. ## Where it goes, per loader `examples/resource_memory.rs` reports, after each resource loader in the game's start order: the live heap (a counting allocator), the step's peak, RSS, and at the end the footprint. Live heap: | loader | vanilla MB | ATM10 42 mods MB | |---|---:|---:| | block registry | 24 | 125 | | assets (registry, models, sprites: 153 MB of pixels for 9,790 layers) | 94 | 657 | | block facts and behaviours | +29 | +75 | | items, recipes | +14 | +82 | | light, mesh, collision, motion | +24 | +53 | | worldgen | +79 | +182 | | **live / footprint** | **240 / 551** | **1,049 / 2,724** | ## Cut in this PR `BlockRegistry` kept every state twice: once in `states`, and again as the key of a `BTreeMap<BlockState, BlockStateId>`. Ids are now indexed by a 64-bit hash of the state and checked against `states`, with a fallback map for hash collisions (empty for vanilla). Probe, alternating base/new runs: | | vanilla | ATM10 42 mods | |---|---:|---:| | live heap | -22 MB | -124 MB | | footprint | -30 MB | -140 to -175 MB | In game with the six mods: about -50 MB RSS. The footprint change is within the noise. ## What's left (documented in docs/modpacks.md) The startup peak. Each loader parses its per-state tables whole, as JSON trees or as NBT trees. For ATM10 the NBT trees are 300-600 MB each (`block-properties.nbt`, the collision, support, occlusion and movement tables). Worldgen loading peaks at 3.9 GB live, and the footprint stays near that peak. Typed, streaming readers for those tables are the next cut. They touch horizon-world's worldgen and collision loaders. ## Checks - `cargo fmt`; `cargo clippy -p horizon-client -p horizon-world --all-targets -D warnings`. - `cargo test -p horizon-world`: all pass. - Local parity: to follow. registry.rs is read by nearly every harness, so this run is as long as #674's. 🤖 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:58:34 +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#2725
No description provided.