[PR #591] [MERGED] Returning to the Overworld reuses its stronghold ring positions #2656

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

📋 Pull Request Information

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

Base: main ← Head: perf/stronghold-ring-cache


📝 Commits (1)

  • 7e43056 Returning to the Overworld reuses its stronghold ring positions

📊 Changes

2 files changed (+85 additions, -5 deletions)

View changed files

📝 crates/horizon-world/src/worldgen/generator.rs (+80 -2)
📝 crates/horizon-world/src/worldgen/generator_structures.rs (+5 -3)

📄 Description

What

Every dimension change builds the destination's generator again (Game::enter_dimension → make_streaming → VanillaTerrain::for_dimension), and with it a new StructureState whose ring positions start empty. So each return to the Overworld ran the 128 stronghold ring searches again (#514 spreads them over the workers, but they still hold up every new chunk until done). Part of #489's freeze when coming back from the Nether.

The ring positions depend only on the generator data (shared by every generator in the process, vanillagen::shared_data), the seed and the dimension's generator definition (biome source and noise settings). GeneratorData now keeps them by (seed, generator JSON), the last eight, as an Arc<OnceLock<Rings>> handed to each StructureState; a generator built again for the same world and dimension gets the cell its predecessor filled. #514's shared RingWork is unchanged: it fills the cell the first time.

Results

Mac mini M4 Pro, fast profile, 2 worker threads (workers:2, about the ThinkPad's 3), seed 1234, render distance 8: load the world, walk through a portal to the Nether, then through a second portal back. A local probe logged the time each thread spent waiting in the ring search after the return.

main this PR
Ring search after returning to the Overworld (both workers blocked) 2.57 s / 0.93 s / 1.14 s none (3 of 3 trips)
Ring search at world load about 0.8–2.8 s the same (the first generator still computes them)
Stronghold from /locate after the return [-3632, ~, -2656] [-3632, ~, -2656]

The total time until no chunk is pending after the return varied 4.7–9.2 s run to run on this loaded machine (portal search, chunk loading) in both builds, so I don't quote it; the stall removed is the ring search above. With 13 workers it is shorter (about 0.5 s since #514) but still delays every new chunk of the return. Frame and tick times don't change: no per-frame or per-tick code is touched.

Same results

The rings are a pure function of the generator data, the seed and the generator definition; the key holds the last two and the first is shared by construction. Eye of ender and /locate give the same stronghold after a round trip (above). Unit test ring_positions_are_shared_by_seed_and_dimension: two generators of one seed share one cell; another seed or generator definition gets its own; the ninth key evicts the oldest. #514's ring_work_shared_between_threads_matches_serial_search still passes.

While measuring: Horizon's /execute in minecraft:the_nether run tp @s … teleports within the current dimension, where vanilla changes dimension. Not changed here; reported as #592.

Self-check

  • cargo fmt --all --check: clean.
  • cargo clippy --workspace --all-targets -- -D warnings: clean.
  • cargo test -p horizon-world (fast profile): 156 passed, 0 failed.
  • Local parity, tools/parity.py --changed origin/main: 287 harnesses affected (generator.rs is upstream of most): 287/287 pass (details in a comment).

Nothing needs Ludovic.

🤖 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/591 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/17/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/stronghold-ring-cache` --- ### 📝 Commits (1) - [`7e43056`](https://github.com/horizon-rust/horizon/commit/7e430564a6d62dbc0816c735bda0bc36bb2e9cd3) Returning to the Overworld reuses its stronghold ring positions ### 📊 Changes **2 files changed** (+85 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-world/src/worldgen/generator.rs` (+80 -2) 📝 `crates/horizon-world/src/worldgen/generator_structures.rs` (+5 -3) </details> ### 📄 Description ## What Every dimension change builds the destination's generator again (`Game::enter_dimension` → `make_streaming` → `VanillaTerrain::for_dimension`), and with it a new `StructureState` whose ring positions start empty. So each return to the Overworld ran the 128 stronghold ring searches again (#514 spreads them over the workers, but they still hold up every new chunk until done). Part of #489's freeze when coming back from the Nether. The ring positions depend only on the generator data (shared by every generator in the process, `vanillagen::shared_data`), the seed and the dimension's generator definition (biome source and noise settings). `GeneratorData` now keeps them by `(seed, generator JSON)`, the last eight, as an `Arc<OnceLock<Rings>>` handed to each `StructureState`; a generator built again for the same world and dimension gets the cell its predecessor filled. #514's shared `RingWork` is unchanged: it fills the cell the first time. ## Results Mac mini M4 Pro, fast profile, **2 worker threads** (`workers:2`, about the ThinkPad's 3), seed 1234, render distance 8: load the world, walk through a portal to the Nether, then through a second portal back. A local probe logged the time each thread spent waiting in the ring search after the return. | | `main` | this PR | | --- | ---: | ---: | | Ring search after returning to the Overworld (both workers blocked) | 2.57 s / 0.93 s / 1.14 s | **none** (3 of 3 trips) | | Ring search at world load | about 0.8–2.8 s | the same (the first generator still computes them) | | Stronghold from `/locate` after the return | [-3632, ~, -2656] | [-3632, ~, -2656] | The total time until no chunk is pending after the return varied 4.7–9.2 s run to run on this loaded machine (portal search, chunk loading) in both builds, so I don't quote it; the stall removed is the ring search above. With 13 workers it is shorter (about 0.5 s since #514) but still delays every new chunk of the return. Frame and tick times don't change: no per-frame or per-tick code is touched. ## Same results The rings are a pure function of the generator data, the seed and the generator definition; the key holds the last two and the first is shared by construction. Eye of ender and `/locate` give the same stronghold after a round trip (above). Unit test `ring_positions_are_shared_by_seed_and_dimension`: two generators of one seed share one cell; another seed or generator definition gets its own; the ninth key evicts the oldest. #514's `ring_work_shared_between_threads_matches_serial_search` still passes. While measuring: Horizon's `/execute in minecraft:the_nether run tp @s …` teleports within the current dimension, where vanilla changes dimension. Not changed here; reported as #592. ## Self-check - `cargo fmt --all --check`: clean. - `cargo clippy --workspace --all-targets -- -D warnings`: clean. - `cargo test -p horizon-world` (fast profile): 156 passed, 0 failed. - Local parity, `tools/parity.py --changed origin/main`: 287 harnesses affected (generator.rs is upstream of most): 287/287 pass (details in a comment). Nothing needs Ludovic. 🤖 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:00 +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#2656
No description provided.