[PR #3367] [MERGED] Decoration: inlined block reads, column scans, per-chunk heightmap reads #4934

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3367
Author: @ThatCakeIsAPie
Created: 10/28/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @levzzz5154

Base: main ← Head: perf/worldgen-decoration-reads


📝 Commits (4)

  • 22f0e30 Block reads: inline the region-to-palette path
  • 1d25065 Decoration: cut per-region and per-shape-update setup
  • 51244a6 Decoration: column scans, per-chunk heightmap reads, zoom-free uniform biomes
  • 779b773 Merge remote-tracking branch 'origin/main' into upd/3367

📊 Changes

10 files changed (+326 additions, -26 deletions)

View changed files

📝 crates/horizon-world/src/chunk.rs (+13 -2)
📝 crates/horizon-world/src/heightmap.rs (+15 -0)
📝 crates/horizon-world/src/worldgen/biome_chunk.rs (+5 -0)
📝 crates/horizon-world/src/worldgen/dripstone.rs (+5 -8)
📝 crates/horizon-world/src/worldgen/feature.rs (+24 -0)
📝 crates/horizon-world/src/worldgen/feature_region.rs (+25 -0)
📝 crates/horizon-world/src/worldgen/generator_decoration.rs (+136 -13)
📝 crates/horizon-world/src/worldgen/terrain.rs (+46 -3)
📝 crates/horizon-world/src/worldgen/tree.rs (+12 -0)
📝 crates/horizon-world/tests/feature_region.rs (+45 -0)

📄 Description

🤖 Opened by ThatCakeIsAPie's AI agent (Claude), not by ThatCakeIsAPie themself.

What and why

Decoration spends much of its time reading blocks, heightmaps and biomes before any feature places anything. Three commits:

  1. Block reads inlined: a block read went through out-of-line calls (the region's chunk lookup, TerrainChunk::block, TerrainBlocks::block and BlockSection::get, whose io::Result error path kept it from inlining). They now inline (the fast build has no cross-crate LTO), and TerrainBlocks reads the section through an infallible accessor: its index is a local index, always below 4096. This leaves PackedStorage alone: #1790 takes the division out of it.
  2. Per-region setup: the biomes present around the chunk come from a bitset instead of a BTreeSet of every quart; each updateShape no longer builds and drops a whole Ticks just to capture the ticks it schedules; the nine stand-in chunks are one section instead of full height.
  3. Read paths: dripstone clusters scan each column through FeatureWorld::scan_column, testing an all-air section once instead of per block; OreFeature's any_height_at_least reads each chunk's part of its square from the heightmap in one pass; placement biome checks skip the zoom where every quart it could pick holds the same biome (worked out once per section per region).

Same blocks, same order of random draws: the decorated chunks are byte for byte the same.

Vanilla reference

DripstoneUtils/DripstoneClusterFeature (column scans), OreFeature.place (WorldGenLevel.getHeight checks), BiomeFilter and BiomeManager.getBiome, WorldGenRegion (shape updates and their scheduled ticks). The feature region and decorated region harnesses cover them.

Measured

Measured against upstream main at 43d8bd01c; the branch is now rebased onto e1b2b0b2f, and upstream hasn't changed the code it touches in between.

chunkgen_bench on vanilla 26.3 worldgen (seed 1234, centre (40, -20), 16 x 16 chunks, --threads 1 --warmup), interleaved with upstream main (43d8bd01c) on one machine (i7, 4 cores / 8 threads, Windows 10). Each figure is the best of the rounds: run C (5 rounds) on a quiet machine, runs A (5) and B (7) while other work loaded it. With all five worldgen PRs together, run C's proto chunk went from 12.88 to 11.33 ms and the median finished chunks/s from 65.2 to 74.1 (+14%).

ms a chunk, one thread (best of rounds) upstream main this branch
decoration, run C (quiet) 1.94 1.62
decoration, run A 1.79 1.63
decoration, run B 1.83 1.69

Output: the terrain and decorated --snapshots are byte for byte those of upstream main in every run (terrain 255010fd759d40b6, decorated 00cec33a9aca9eac at 16 x 16; also at 24 x 24 on six threads: d92fd1c14b5665f0 / f5683617d95b87b0).

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main on DESKTOP-LT6RAH8, against upstream/main at e1b2b0b2f, 22 min 56 s)

Check Result
Scope ✅ 10 files, +326 −26
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 401 run, FAILED (failures=1, errors=1, skipped=1) (7 min 27 s)
rustfmt ✅ (1 min 26 s)
clippy ✅ (9 min 5 s)
tests: horizon-world ✅ 257 passed (4 min 33 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 ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The Python tests that fail here fail the same way on upstream main on this Windows machine (symlink privilege, path separators); they're independent of this change, and CI runs them on Linux.

Label: none (players get the same worlds, generated faster).

🤖 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/3367 **Author:** [@ThatCakeIsAPie](https://github.com/ThatCakeIsAPie) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `perf/worldgen-decoration-reads` --- ### 📝 Commits (4) - [`22f0e30`](https://github.com/horizon-rust/horizon/commit/22f0e30d07827ac8ee8380f3027fea7a9bb276e7) Block reads: inline the region-to-palette path - [`1d25065`](https://github.com/horizon-rust/horizon/commit/1d25065363cdddd9d9d31f9e20282a8dcb960ae5) Decoration: cut per-region and per-shape-update setup - [`51244a6`](https://github.com/horizon-rust/horizon/commit/51244a64f6b54fb2d84e13160c123d89cc7d463d) Decoration: column scans, per-chunk heightmap reads, zoom-free uniform biomes - [`779b773`](https://github.com/horizon-rust/horizon/commit/779b7735309b882eec4967abe9b82ea6b2cb215b) Merge remote-tracking branch 'origin/main' into upd/3367 ### 📊 Changes **10 files changed** (+326 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-world/src/chunk.rs` (+13 -2) 📝 `crates/horizon-world/src/heightmap.rs` (+15 -0) 📝 `crates/horizon-world/src/worldgen/biome_chunk.rs` (+5 -0) 📝 `crates/horizon-world/src/worldgen/dripstone.rs` (+5 -8) 📝 `crates/horizon-world/src/worldgen/feature.rs` (+24 -0) 📝 `crates/horizon-world/src/worldgen/feature_region.rs` (+25 -0) 📝 `crates/horizon-world/src/worldgen/generator_decoration.rs` (+136 -13) 📝 `crates/horizon-world/src/worldgen/terrain.rs` (+46 -3) 📝 `crates/horizon-world/src/worldgen/tree.rs` (+12 -0) 📝 `crates/horizon-world/tests/feature_region.rs` (+45 -0) </details> ### 📄 Description > 🤖 Opened by ThatCakeIsAPie's AI agent (Claude), not by ThatCakeIsAPie themself. ## What and why Decoration spends much of its time reading blocks, heightmaps and biomes before any feature places anything. Three commits: 1. **Block reads inlined**: a block read went through out-of-line calls (the region's chunk lookup, `TerrainChunk::block`, `TerrainBlocks::block` and `BlockSection::get`, whose `io::Result` error path kept it from inlining). They now inline (the fast build has no cross-crate LTO), and `TerrainBlocks` reads the section through an infallible accessor: its index is a local index, always below 4096. This leaves `PackedStorage` alone: #1790 takes the division out of it. 2. **Per-region setup**: the biomes present around the chunk come from a bitset instead of a `BTreeSet` of every quart; each `updateShape` no longer builds and drops a whole `Ticks` just to capture the ticks it schedules; the nine stand-in chunks are one section instead of full height. 3. **Read paths**: dripstone clusters scan each column through `FeatureWorld::scan_column`, testing an all-air section once instead of per block; `OreFeature`'s `any_height_at_least` reads each chunk's part of its square from the heightmap in one pass; placement biome checks skip the zoom where every quart it could pick holds the same biome (worked out once per section per region). Same blocks, same order of random draws: the decorated chunks are byte for byte the same. ## Vanilla reference `DripstoneUtils`/`DripstoneClusterFeature` (column scans), `OreFeature.place` (`WorldGenLevel.getHeight` checks), `BiomeFilter` and `BiomeManager.getBiome`, `WorldGenRegion` (shape updates and their scheduled ticks). The feature region and decorated region harnesses cover them. ## Measured Measured against upstream main at 43d8bd01c; the branch is now rebased onto e1b2b0b2f, and upstream hasn't changed the code it touches in between. `chunkgen_bench` on vanilla 26.3 worldgen (seed 1234, centre (40, -20), 16 x 16 chunks, `--threads 1 --warmup`), interleaved with upstream main (43d8bd01c) on one machine (i7, 4 cores / 8 threads, Windows 10). Each figure is the best of the rounds: run C (5 rounds) on a quiet machine, runs A (5) and B (7) while other work loaded it. With all five worldgen PRs together, run C's proto chunk went from 12.88 to 11.33 ms and the median finished chunks/s from 65.2 to 74.1 (+14%). | ms a chunk, one thread (best of rounds) | upstream main | this branch | |---|---|---| | decoration, run C (quiet) | 1.94 | 1.62 | | decoration, run A | 1.79 | 1.63 | | decoration, run B | 1.83 | 1.69 | Output: the terrain and decorated `--snapshot`s are byte for byte those of upstream main in every run (terrain `255010fd759d40b6`, decorated `00cec33a9aca9eac` at 16 x 16; also at 24 x 24 on six threads: `d92fd1c14b5665f0` / `f5683617d95b87b0`). ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on DESKTOP-LT6RAH8, against upstream/main at e1b2b0b2f, 22 min 56 s) | Check | Result | | --- | --- | | Scope | ✅ 10 files, +326 −26 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 401 run, FAILED (failures=1, errors=1, skipped=1) (7 min 27 s) | | rustfmt | ✅ (1 min 26 s) | | clippy | ✅ (9 min 5 s) | | tests: horizon-world | ✅ 257 passed (4 min 33 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 | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The Python tests that fail here fail the same way on upstream main on this Windows machine (symlink privilege, path separators); they're independent of this change, and CI runs them on Linux. Label: none (players get the same worlds, generated faster). 🤖 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:09: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#4934
No description provided.