[PR #5040] [MERGED] Generated columns: read a whole section in one pass #6023

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5040
Author: @apeirs
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: column-bulk-section-read


📝 Commits (1)

  • 83189a8 Generated columns: read a whole section in one pass

📊 Changes

4 files changed (+84 additions, -7 deletions)

View changed files

📝 crates/horizon-client/src/vanillagen.rs (+14 -7)
📝 crates/horizon-core/src/storage.rs (+10 -0)
📝 crates/horizon-world/src/chunk.rs (+39 -0)
📝 crates/horizon-world/src/worldgen/terrain.rs (+21 -0)

📄 Description

🤖 Opened by apeirs's AI agent (Claude Code, Claude Opus 5.5), not by apeirs personally.

What and why

Fixes #5038. VanillaTerrain::column copied a generated chunk block by block (ProtoChunk::block per block: section lookup, coordinates, palette read; ~98k calls a chunk) before Section::from_blocks. Light views for the ring past the view distance are built on the server thread (Streaming::light_region → light_view → column), and while the player moves that ring keeps advancing.

  • PackedStorage::unpack_into: unpack into a caller's buffer, no allocation.
  • BlockSection::fill_states: every state of a section in index order, as state reads them one by one.
  • TerrainChunk::section_states(y, out): a whole section of the chunk in (y << 8) | (z << 4) | x order; an all-air section (non_air == 0) fills with air, as TerrainBlocks::block returns it.
  • column reads a whole generated section through it; a partly generated one keeps the per-block loop. Section::from_blocks and everything after it are unchanged.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

None: an internal copy between Horizon's own chunk types. The values are the same, so world generation, light and saves are unchanged.

Measurements

i7-11850H laptop, nightly 587f81f fast builds, a copied survival world, render distance 24, a 40 s spectator flight at 50 blocks/s into new terrain, CPU sampled at 997 Hz inside the game (pprof) for 30 s:

VanillaTerrain::column on the server thread ProtoChunk::block
main 27.7 % (616 samples) 13.7 %
this PR 12.0 % (290 samples) gone

What is left is Section::from_blocks (packing), unchanged.

Equivalence: a verify build computed every bulk-read section both ways during the same kind of flight: 214 152 sections, 0 mismatched blocks. New unit test chunk::tests::fill_states_matches_state checks fill_states against state at every index across palette widths (uniform section without storage, then 2, 16, 17, 64 distinct states under random edits).

Self-check

tools/pr_ready.py --quick on this machine (Linux x86_64) passed Public tree, Python tests (495), rustfmt and clippy, then the test build hit a full disk (No space left on device, then a linker bus error), unrelated to the change. I ran CI's commands on a second machine instead (Windows on ARM, Snapdragon X, native build):

Check Result
cargo fmt --all -- --check ✅
cargo clippy --workspace --all-targets --locked -- -D warnings ✅
cargo clippy -p horizon-client --all-targets --locked --no-default-features -- -D warnings ✅
cargo test --locked -p horizon-client -p horizon-core -p horizon-world --lib --bins --tests ✅ 1 766 passed
cargo test --locked -p horizon-client -p horizon-core -p horizon-world --doc ✅

🤖 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/5040 **Author:** [@apeirs](https://github.com/apeirs) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `column-bulk-section-read` --- ### 📝 Commits (1) - [`83189a8`](https://github.com/horizon-rust/horizon/commit/83189a8ae79ab16a613cc9d5aad51aa6f09e8dc5) Generated columns: read a whole section in one pass ### 📊 Changes **4 files changed** (+84 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/vanillagen.rs` (+14 -7) 📝 `crates/horizon-core/src/storage.rs` (+10 -0) 📝 `crates/horizon-world/src/chunk.rs` (+39 -0) 📝 `crates/horizon-world/src/worldgen/terrain.rs` (+21 -0) </details> ### 📄 Description > 🤖 Opened by apeirs's AI agent (Claude Code, Claude Opus 5.5), not by apeirs personally. ## What and why Fixes #5038. `VanillaTerrain::column` copied a generated chunk block by block (`ProtoChunk::block` per block: section lookup, coordinates, palette read; ~98k calls a chunk) before `Section::from_blocks`. Light views for the ring past the view distance are built on the server thread (`Streaming::light_region` → `light_view` → `column`), and while the player moves that ring keeps advancing. - `PackedStorage::unpack_into`: `unpack` into a caller's buffer, no allocation. - `BlockSection::fill_states`: every state of a section in index order, as `state` reads them one by one. - `TerrainChunk::section_states(y, out)`: a whole section of the chunk in `(y << 8) | (z << 4) | x` order; an all-air section (`non_air == 0`) fills with `air`, as `TerrainBlocks::block` returns it. - `column` reads a whole generated section through it; a partly generated one keeps the per-block loop. `Section::from_blocks` and everything after it are unchanged. ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [x] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference None: an internal copy between Horizon's own chunk types. The values are the same, so world generation, light and saves are unchanged. ## Measurements i7-11850H laptop, nightly 587f81f `fast` builds, a copied survival world, render distance 24, a 40 s spectator flight at 50 blocks/s into new terrain, CPU sampled at 997 Hz inside the game (`pprof`) for 30 s: | | `VanillaTerrain::column` on the server thread | `ProtoChunk::block` | |---|---|---| | main | 27.7 % (616 samples) | 13.7 % | | this PR | 12.0 % (290 samples) | gone | What is left is `Section::from_blocks` (packing), unchanged. **Equivalence:** a verify build computed every bulk-read section both ways during the same kind of flight: 214 152 sections, 0 mismatched blocks. New unit test `chunk::tests::fill_states_matches_state` checks `fill_states` against `state` at every index across palette widths (uniform section without storage, then 2, 16, 17, 64 distinct states under random edits). ## Self-check `tools/pr_ready.py --quick` on this machine (Linux x86_64) passed Public tree, Python tests (495), rustfmt and clippy, then the test build hit a full disk (`No space left on device`, then a linker bus error), unrelated to the change. I ran CI's commands on a second machine instead (Windows on ARM, Snapdragon X, native build): | Check | Result | | --- | --- | | `cargo fmt --all -- --check` | ✅ | | `cargo clippy --workspace --all-targets --locked -- -D warnings` | ✅ | | `cargo clippy -p horizon-client --all-targets --locked --no-default-features -- -D warnings` | ✅ | | `cargo test --locked -p horizon-client -p horizon-core -p horizon-world --lib --bins --tests` | ✅ 1 766 passed | | `cargo test --locked -p horizon-client -p horizon-core -p horizon-world --doc` | ✅ | 🤖 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:16:41 +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#6023
No description provided.