[PR #4092] [MERGED] Worldgen: bind the feature block tags once, shared by decoration, structures and live features #5412

Closed
opened 2026-11-03 05:12:25 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: perf/shared-feature-block-tags


📝 Commits (1)

  • a536b00 Worldgen: bind the feature block tags once, shared by decoration, structures and live features

📊 Changes

6 files changed (+66 additions, -23 deletions)

View changed files

📝 crates/horizon-world/src/worldgen/block_feature.rs (+37 -9)
📝 crates/horizon-world/src/worldgen/feature_region.rs (+1 -1)
📝 crates/horizon-world/src/worldgen/generator.rs (+19 -0)
📝 crates/horizon-world/src/worldgen/generator_decoration.rs (+4 -4)
📝 crates/horizon-world/src/worldgen/generator_structures.rs (+1 -5)
📝 crates/horizon-world/src/worldgen/live.rs (+4 -4)

📄 Description

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

What and why

Fourth PR of the server plan (#3989, docs/server-next.md §7). Independent of #4009, #4027 and #4078.

Decoration (generator_decoration.rs), structure placement (generator_structures.rs) and live features
(live.rs) each called FeatureBlockBindings::with_tags over the same registry and the same data.block_tags.
Each call bound every block and every block tag to a fresh BTreeSet of states: 5.5 MB per call on the live heap,
the same three times.

GeneratorData::feature_block_bindings now binds them once (bind_tags, kept in a OnceLock), and the three
bindings share the two maps through Arcs (with_bound_tags). with_tags keeps its signature for its other
callers. FeatureRegion::with_block_bindings, which cloned the whole tag map for every decorated region, now
clones an Arc. Nothing that reads the maps changes, so decoration results are the same.

Measured

Mac mini M4 Pro, fresh scratch dedicated server, seed 12345, nobody on. Main d6adbe1cb against this branch.

Malloc "allocated" bytes from vmmap -summary, 30 s after start, 2 runs each:

run 1 run 2
main 538.7 MB, 2,669,288 nodes 538.8 MB, 2,669,162 nodes
this PR 527.3 MB, 2,514,065 nodes 526.9 MB, 2,514,067 nodes

That is −11.6 MB and 155,000 fewer live allocations.

sn_idle.py RSS 10 s after ready, 4 interleaved pairs at load 40–63: main 834/836/845/829 MB (median 835),
this PR 832/821/851/819 MB (median 827). On this busy machine the same binary's RSS swings by up to 70 MB
between runs (memory pressure), so the allocated bytes above are the reliable number. Ready times were inside
the noise.

Self-check

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at d6adbe1cb, 4 min 8 s)

Check Result
Scope ✅ 6 files, +66 −23
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 475 passed (1 min 8 s)
rustfmt ✅ (5 s)
clippy ✅ (1 min 24 s)
tests: horizon-world ✅ 276 passed (1 min 13 s)
doc tests ✅ 0 passed (2 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 154 affected, to run in CI (--quick): ambient_sound, arrow, attribute_updates, audio_attributes, auto_jump, bamboo, biome_weather, block_blob, block_column, block_entity_anim, block_entity_render, block_entity_tickers and 142 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Parity: run-parity label for CI; worldgen reaches 154 harnesses.

🤖 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/4092 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/shared-feature-block-tags` --- ### 📝 Commits (1) - [`a536b00`](https://github.com/horizon-rust/horizon/commit/a536b00c30c15e3aff9540410113cf623cf358f1) Worldgen: bind the feature block tags once, shared by decoration, structures and live features ### 📊 Changes **6 files changed** (+66 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-world/src/worldgen/block_feature.rs` (+37 -9) 📝 `crates/horizon-world/src/worldgen/feature_region.rs` (+1 -1) 📝 `crates/horizon-world/src/worldgen/generator.rs` (+19 -0) 📝 `crates/horizon-world/src/worldgen/generator_decoration.rs` (+4 -4) 📝 `crates/horizon-world/src/worldgen/generator_structures.rs` (+1 -5) 📝 `crates/horizon-world/src/worldgen/live.rs` (+4 -4) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What and why Fourth PR of the server plan (#3989, `docs/server-next.md` §7). Independent of #4009, #4027 and #4078. Decoration (`generator_decoration.rs`), structure placement (`generator_structures.rs`) and live features (`live.rs`) each called `FeatureBlockBindings::with_tags` over the same registry and the same `data.block_tags`. Each call bound every block and every block tag to a fresh `BTreeSet` of states: 5.5 MB per call on the live heap, the same three times. `GeneratorData::feature_block_bindings` now binds them once (`bind_tags`, kept in a `OnceLock`), and the three bindings share the two maps through `Arc`s (`with_bound_tags`). `with_tags` keeps its signature for its other callers. `FeatureRegion::with_block_bindings`, which cloned the whole tag map for every decorated region, now clones an `Arc`. Nothing that reads the maps changes, so decoration results are the same. ## Measured Mac mini M4 Pro, fresh scratch dedicated server, seed 12345, nobody on. Main d6adbe1cb against this branch. Malloc "allocated" bytes from `vmmap -summary`, 30 s after start, 2 runs each: | | run 1 | run 2 | |---|---|---| | main | 538.7 MB, 2,669,288 nodes | 538.8 MB, 2,669,162 nodes | | this PR | **527.3 MB**, 2,514,065 nodes | **526.9 MB**, 2,514,067 nodes | That is −11.6 MB and 155,000 fewer live allocations. `sn_idle.py` RSS 10 s after ready, 4 interleaved pairs at load 40–63: main 834/836/845/829 MB (median 835), this PR 832/821/851/819 MB (median 827). On this busy machine the same binary's RSS swings by up to 70 MB between runs (memory pressure), so the allocated bytes above are the reliable number. Ready times were inside the noise. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at d6adbe1cb, 4 min 8 s) | Check | Result | | --- | --- | | Scope | ✅ 6 files, +66 −23 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 475 passed (1 min 8 s) | | rustfmt | ✅ (5 s) | | clippy | ✅ (1 min 24 s) | | tests: horizon-world | ✅ 276 passed (1 min 13 s) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 154 affected, to run in CI (--quick): ambient_sound, arrow, attribute_updates, audio_attributes, auto_jump, bamboo, biome_weather, block_blob, block_column, block_entity_anim, block_entity_render, block_entity_tickers and 142 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Parity: `run-parity` label for CI; worldgen reaches 154 harnesses. 🤖 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 05:12:25 +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#5412
No description provided.