[PR #3281] [MERGED] Worldgen: build a biome source's feature decoration once, ahead of the world #4888

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

📋 Pull Request Information

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

Base: main ← Head: perf/world-entry-decoration-cache


📝 Commits (1)

  • 6f6229c Worldgen: build a biome source's feature decoration once, ahead of the world

📊 Changes

2 files changed (+108 additions, -7 deletions)

View changed files

📝 crates/horizon-client/src/game/world_loading.rs (+6 -2)
📝 crates/horizon-world/src/worldgen/generator.rs (+102 -5)

📄 Description

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

Roadmap item world-entry, second part (the first was #3250). Leftover named in the item's notes: "OverworldGenerator::for_world (seed-dependent) still costs 0.2-0.46 s on every world open".

What was slow

Timing marks around the integrated server's world opening (reload, through the Singleplayer screen, so #2481's preload had already read the worldgen bundle) gave, out of ~0.57 s to the first controllable frame:

step ms
server Game setup ~54
OverworldGenerator::for_world ~185
  of which Decoration::new ~139
  of which biome source decode / structure state 14 / 24
live features ~50
finish_open_world ~39
connect through memory 35–65

Decoration::new decodes the placed features of every biome the dimension's biome source can place. Nothing in it depends on the seed: only on the worldgen resources and the biome source.

The change

  • GeneratorData::decoration_for keeps the decoration by biome source definition (an Arc<OnceLock> per source, like rings_for's ring cache; up to 4 sources). Every generator built for that source shares it; a caller that arrives while another builds it waits for that build.
  • GeneratorData::prepare_decoration(preset, dimension) builds it ahead of time. The world screens' preload (preload_world_data, #2481) calls it for the Overworld after reading the bundle, while the player is still on the Singleplayer / Create World screen.
  • Reopening a world, creating another, or returning to a dimension in the same session builds nothing again.

World output is unchanged: the same Decoration value is built from the same inputs, only once. The decoration's lazily decoded named features (named) are seed-independent too.

Numbers

Mac mini M4 Pro, --profile fast, --offscreen, seed 1234, RD 12, 2 workers (workers:2), server thread, driven through the Singleplayer screen then open, fresh mktemp -d homes (HORIZON_HOME, HORIZON_LAUNCHER_HOME, XDG_DATA_HOME, XDG_CONFIG_HOME, HORIZON_NO_AUDIO=1). Five runs each, alternated with main 8993772de; medians (the Mac was heavily loaded by other jobs, load average 30–46, so the spread is wide):

main this PR
create: client joined 0.45 s (0.42–0.51) 0.31 s (0.27–0.34)
reload: client joined 0.46 s (0.41–0.51) 0.31 s (0.29–0.36)
reload: first controllable frame 0.60 s 0.42 s
create: first controllable frame 0.85 s 0.79 s

(Create's first frame also waits for the spawn chunks to generate, so it gains less.)

New test: decoration_is_shared_by_biome_source (two seeds share the preload's decoration; the Nether gets its own).

Checks

pr_ready (tools/pr_ready.py on ludovics-mac-mini, against origin/main at 8993772de, 55 min 58 s)

Check Result
Scope ✅ 2 files, +108 −7
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 401 passed (1 min 37 s)
rustfmt ✅ (14 s)
clippy ✅ (34 s)
tests: horizon-client, horizon-world ✅ 1519 passed (4 min 11 s)
doc tests ✅ 0 passed (38 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 ✅ 94 affected, 93 passed (48 min 24 s)
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The one affected harness not run is lan_integration (the whole lan_e2e suite, run by name only).

🤖 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/3281 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 10/28/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/world-entry-decoration-cache` --- ### 📝 Commits (1) - [`6f6229c`](https://github.com/horizon-rust/horizon/commit/6f6229c2d436239df750a08fc2b9c21d80e9ff49) Worldgen: build a biome source's feature decoration once, ahead of the world ### 📊 Changes **2 files changed** (+108 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/world_loading.rs` (+6 -2) 📝 `crates/horizon-world/src/worldgen/generator.rs` (+102 -5) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Roadmap item `world-entry`, second part (the first was #3250). Leftover named in the item's notes: "`OverworldGenerator::for_world` (seed-dependent) still costs 0.2-0.46 s on every world open". ## What was slow Timing marks around the integrated server's world opening (reload, through the Singleplayer screen, so #2481's preload had already read the worldgen bundle) gave, out of ~0.57 s to the first controllable frame: | step | ms | |---|---| | server `Game` setup | ~54 | | `OverworldGenerator::for_world` | ~185 | | &nbsp;&nbsp;of which `Decoration::new` | **~139** | | &nbsp;&nbsp;of which biome source decode / structure state | 14 / 24 | | live features | ~50 | | `finish_open_world` | ~39 | | connect through memory | 35–65 | `Decoration::new` decodes the placed features of every biome the dimension's biome source can place. Nothing in it depends on the seed: only on the worldgen resources and the biome source. ## The change - `GeneratorData::decoration_for` keeps the decoration by biome source definition (an `Arc<OnceLock>` per source, like `rings_for`'s ring cache; up to 4 sources). Every generator built for that source shares it; a caller that arrives while another builds it waits for that build. - `GeneratorData::prepare_decoration(preset, dimension)` builds it ahead of time. The world screens' preload (`preload_world_data`, #2481) calls it for the Overworld after reading the bundle, while the player is still on the Singleplayer / Create World screen. - Reopening a world, creating another, or returning to a dimension in the same session builds nothing again. World output is unchanged: the same `Decoration` value is built from the same inputs, only once. The decoration's lazily decoded named features (`named`) are seed-independent too. ## Numbers Mac mini M4 Pro, `--profile fast`, `--offscreen`, seed 1234, RD 12, 2 workers (`workers:2`), server thread, driven through the Singleplayer screen then `open`, fresh `mktemp -d` homes (`HORIZON_HOME`, `HORIZON_LAUNCHER_HOME`, `XDG_DATA_HOME`, `XDG_CONFIG_HOME`, `HORIZON_NO_AUDIO=1`). Five runs each, alternated with main 8993772de; medians (the Mac was heavily loaded by other jobs, load average 30–46, so the spread is wide): | | main | this PR | |---|---|---| | create: client joined | 0.45 s (0.42–0.51) | **0.31 s** (0.27–0.34) | | reload: client joined | 0.46 s (0.41–0.51) | **0.31 s** (0.29–0.36) | | reload: first controllable frame | 0.60 s | **0.42 s** | | create: first controllable frame | 0.85 s | 0.79 s | (Create's first frame also waits for the spawn chunks to generate, so it gains less.) New test: `decoration_is_shared_by_biome_source` (two seeds share the preload's decoration; the Nether gets its own). ## Checks **pr_ready** (`tools/pr_ready.py` on ludovics-mac-mini, against origin/main at 8993772de, 55 min 58 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +108 −7 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 401 passed (1 min 37 s) | | rustfmt | ✅ (14 s) | | clippy | ✅ (34 s) | | tests: horizon-client, horizon-world | ✅ 1519 passed (4 min 11 s) | | doc tests | ✅ 0 passed (38 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 | ✅ 94 affected, 93 passed (48 min 24 s) | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The one affected harness not run is `lan_integration` (the whole lan_e2e suite, run by name only). 🤖 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:08:40 +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#4888
No description provided.