[PR #3365] [MERGED] Biome stage: build free neighbour biome chunks first, cheaper id lookups #4930

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/3365
Author: @ThatCakeIsAPie
Created: 10/28/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @levzzz5154

Base: main ← Head: perf/worldgen-biome-stage


📝 Commits (3)

  • 483ad52 Biome stage: build free neighbour biome chunks before waiting
  • 5a75089 Biome stage: biome ids by bitset, names by a last-entry memo
  • e60455d Merge main into perf/worldgen-biome-stage

📊 Changes

1 file changed (+76 additions, -20 deletions)

View changed files

📝 crates/horizon-world/src/worldgen/generator.rs (+76 -20)

📄 Description

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

What and why

Three changes to the biome stage of chunk generation:

  • Free neighbours first: each chunk needs the biome chunks of its 3x3 neighbourhood, built once by whichever worker gets there first (per-chunk work lock). With several workers on neighbouring chunks, a worker often blocked on a neighbour another worker was building, while other neighbours were still unbuilt. The stage now first builds (or reads) every neighbour whose lock is free (try_lock), then waits for the ones still being built. This is the same idea as #1760 for structure starts. Each biome chunk is still built exactly once, deterministically; only the order of the work changes.
  • Biome ids by bitset: the ids present around the chunk were gathered by inserting every quart of the nine neighbours into a BTreeSet. A bitset gives the same ids in the same ascending order.
  • Names by a last-entry memo: names point into the biome source's parameter list, and neighbouring quarts mostly resolve to the same entry, so the map lookup only runs when the name changes.

Vanilla reference

None changed: the biomes are those of MultiNoiseBiomeSource as before (chunk generation, biome source and biome zoom harnesses).

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
biome stage, run C (quiet) 0.71 0.61
biome stage, run B 0.70 0.58

The lock-wait part only shows with several workers: on 6 threads the biome stage went from about 1.1 to 1.0 ms a chunk in an earlier run. 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, 9 min 7 s)

Check Result
Scope ✅ 1 files, +76 −20
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 401 run, FAILED (failures=1, errors=1, skipped=1) (2 min 16 s)
rustfmt ✅ (14 s)
clippy ✅ (3 min 18 s)
tests: horizon-world ✅ 256 passed (3 min 8 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/3365 **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-biome-stage` --- ### 📝 Commits (3) - [`483ad52`](https://github.com/horizon-rust/horizon/commit/483ad5209cf83b37c244583cb8c85d30337449b8) Biome stage: build free neighbour biome chunks before waiting - [`5a75089`](https://github.com/horizon-rust/horizon/commit/5a75089f61c9c6b9441663e643253e033595caa7) Biome stage: biome ids by bitset, names by a last-entry memo - [`e60455d`](https://github.com/horizon-rust/horizon/commit/e60455d12cd97feb9e32b02eeb857e5100d62879) Merge main into perf/worldgen-biome-stage ### 📊 Changes **1 file changed** (+76 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-world/src/worldgen/generator.rs` (+76 -20) </details> ### 📄 Description > 🤖 Opened by ThatCakeIsAPie's AI agent (Claude), not by ThatCakeIsAPie themself. ## What and why Three changes to the biome stage of chunk generation: - **Free neighbours first**: each chunk needs the biome chunks of its 3x3 neighbourhood, built once by whichever worker gets there first (per-chunk work lock). With several workers on neighbouring chunks, a worker often blocked on a neighbour another worker was building, while other neighbours were still unbuilt. The stage now first builds (or reads) every neighbour whose lock is free (`try_lock`), then waits for the ones still being built. This is the same idea as #1760 for structure starts. Each biome chunk is still built exactly once, deterministically; only the order of the work changes. - **Biome ids by bitset**: the ids present around the chunk were gathered by inserting every quart of the nine neighbours into a `BTreeSet`. A bitset gives the same ids in the same ascending order. - **Names by a last-entry memo**: names point into the biome source's parameter list, and neighbouring quarts mostly resolve to the same entry, so the map lookup only runs when the name changes. ## Vanilla reference None changed: the biomes are those of `MultiNoiseBiomeSource` as before (chunk generation, biome source and biome zoom harnesses). ## 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 | |---|---|---| | biome stage, run C (quiet) | 0.71 | 0.61 | | biome stage, run B | 0.70 | 0.58 | The lock-wait part only shows with several workers: on 6 threads the biome stage went from about 1.1 to 1.0 ms a chunk in an earlier run. 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, 9 min 7 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +76 −20 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 401 run, FAILED (failures=1, errors=1, skipped=1) (2 min 16 s) | | rustfmt | ✅ (14 s) | | clippy | ✅ (3 min 18 s) | | tests: horizon-world | ✅ 256 passed (3 min 8 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#4930
No description provided.