[PR #3366] [MERGED] Surface rules: biome ids instead of names, and a cell cache for mixed quart cells #4933

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

Base: main ← Head: perf/worldgen-surface-biomes


📝 Commits (4)

  • d4a1eba Surface rules: compare biome ids, not names
  • c8f484e Surface biomes: keep each quart cell's corner jitter and biomes
  • 8418564 Merge main into perf/worldgen-surface-biomes
  • 52cc53a Surface rules: an empty biome list keeps the name lookup

📊 Changes

7 files changed (+237 additions, -33 deletions)

View changed files

📝 crates/horizon-core/src/biome.rs (+74 -0)
📝 crates/horizon-world/src/worldgen/biome_chunk.rs (+3 -0)
📝 crates/horizon-world/src/worldgen/generator.rs (+75 -31)
📝 crates/horizon-world/src/worldgen/material_condition.rs (+55 -1)
📝 crates/horizon-world/src/worldgen/material_condition/density.rs (+6 -0)
📝 crates/horizon-world/src/worldgen/material_condition/noise.rs (+6 -0)
📝 crates/horizon-world/tests/material_rule_specialization.rs (+18 -1)

📄 Description

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

What and why

The surface stage asks every solid block's biome, often several times (one per biome condition in the rule):

  • Biome ids, not names: each biome condition cloned and dropped the biome's Arc<str> (an atomic count all generator threads share) and looked the name up in a string set. Queries that number their biomes (the generator's) now answer with the index, and biome conditions keep a bit per index; other queries compare names as before. Same answers: the generator's name -> id map is exact. It works with the per-band rule specialisation (dbafda06e): the specialised tree clones the new condition kind.
  • Mixed quart cells: the per-chunk cell cache only proved cells whose eight quart corners hold one biome. A block in any other cell ran the full eight-corner zoom mix and a stored lookup again. Now a mixed cell keeps its corners' jitter (BiomeZoom::corner_jitter, one mix per cell) and their eight biomes, so each block of the cell only redoes the distance comparison (BiomeZoom::select_corner, same arithmetic and tie order). The cell of the previous lookup is kept too, as columns walk down in y. A test checks the split zoom against quart_at_block.

Vanilla reference

BiomeManager.getBiome (the zoom: getFiddledDistance, corner order and ties) and SurfaceRules.BiomeConditionSource. The material surface and biome zoom 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
surface stage, run C (quiet) 4.56 4.17
surface stage, run A 4.28 4.00
surface stage, run B 4.49 4.30

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, 12 min 43 s)

Check Result
Scope ✅ 6 files, +216 −32
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 401 run, FAILED (failures=1, errors=1, skipped=1) (1 min 33 s)
rustfmt ✅ (14 s)
clippy ✅ (3 min 59 s)
tests: horizon-core, horizon-world ✅ 371 passed (6 min 43 s)
doc tests ✅ 0 passed (10 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/3366 **Author:** [@ThatCakeIsAPie](https://github.com/ThatCakeIsAPie) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/worldgen-surface-biomes` --- ### 📝 Commits (4) - [`d4a1eba`](https://github.com/horizon-rust/horizon/commit/d4a1ebaa339a73b546da5fdc2e307c49ba23d903) Surface rules: compare biome ids, not names - [`c8f484e`](https://github.com/horizon-rust/horizon/commit/c8f484e0400a00d287ed9f66647e93c19eef3789) Surface biomes: keep each quart cell's corner jitter and biomes - [`8418564`](https://github.com/horizon-rust/horizon/commit/84185641bc06215879f09cbc755a362f7c3b41f9) Merge main into perf/worldgen-surface-biomes - [`52cc53a`](https://github.com/horizon-rust/horizon/commit/52cc53a4f983c264aff76b30aca91bde1cb43e02) Surface rules: an empty biome list keeps the name lookup ### 📊 Changes **7 files changed** (+237 additions, -33 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-core/src/biome.rs` (+74 -0) 📝 `crates/horizon-world/src/worldgen/biome_chunk.rs` (+3 -0) 📝 `crates/horizon-world/src/worldgen/generator.rs` (+75 -31) 📝 `crates/horizon-world/src/worldgen/material_condition.rs` (+55 -1) 📝 `crates/horizon-world/src/worldgen/material_condition/density.rs` (+6 -0) 📝 `crates/horizon-world/src/worldgen/material_condition/noise.rs` (+6 -0) 📝 `crates/horizon-world/tests/material_rule_specialization.rs` (+18 -1) </details> ### 📄 Description > 🤖 Opened by ThatCakeIsAPie's AI agent (Claude), not by ThatCakeIsAPie themself. ## What and why The surface stage asks every solid block's biome, often several times (one per biome condition in the rule): - **Biome ids, not names**: each biome condition cloned and dropped the biome's `Arc<str>` (an atomic count all generator threads share) and looked the name up in a string set. Queries that number their biomes (the generator's) now answer with the index, and biome conditions keep a bit per index; other queries compare names as before. Same answers: the generator's name -> id map is exact. It works with the per-band rule specialisation (dbafda06e): the specialised tree clones the new condition kind. - **Mixed quart cells**: the per-chunk cell cache only proved cells whose eight quart corners hold one biome. A block in any other cell ran the full eight-corner zoom mix and a stored lookup again. Now a mixed cell keeps its corners' jitter (`BiomeZoom::corner_jitter`, one mix per cell) and their eight biomes, so each block of the cell only redoes the distance comparison (`BiomeZoom::select_corner`, same arithmetic and tie order). The cell of the previous lookup is kept too, as columns walk down in y. A test checks the split zoom against `quart_at_block`. ## Vanilla reference `BiomeManager.getBiome` (the zoom: `getFiddledDistance`, corner order and ties) and `SurfaceRules.BiomeConditionSource`. The material surface and biome zoom 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 | |---|---|---| | surface stage, run C (quiet) | 4.56 | 4.17 | | surface stage, run A | 4.28 | 4.00 | | surface stage, run B | 4.49 | 4.30 | 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, 12 min 43 s) | Check | Result | | --- | --- | | Scope | ✅ 6 files, +216 −32 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 401 run, FAILED (failures=1, errors=1, skipped=1) (1 min 33 s) | | rustfmt | ✅ (14 s) | | clippy | ✅ (3 min 59 s) | | tests: horizon-core, horizon-world | ✅ 371 passed (6 min 43 s) | | doc tests | ✅ 0 passed (10 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#4933
No description provided.