[PR #1229] [MERGED] Reuse aquifer neighborhoods to speed up Overworld generation #3435

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

📋 Pull Request Information

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

Base: main ← Head: perf/aquifer-neighborhood


📝 Commits (3)

  • 97edfec perf: reuse decoded aquifer neighborhoods during terrain fill
  • a648622 bench: report exact warmed generation wall timings
  • b054c8d Remove benchmark report from pull request

📊 Changes

2 files changed (+105 additions, -39 deletions)

View changed files

📝 crates/horizon-world/examples/chunkgen_bench.rs (+37 -1)
📝 crates/horizon-world/src/worldgen/aquifer/noise_based.rs (+68 -38)

📄 Description

What and why

Aquifer samples repeatedly check and unpack the same twelve neighboring cell positions as terrain filling walks a grid cell. Cache that decoded neighborhood until the grid key changes, publishing a replacement only after every checked access succeeds. Explicit four-slot nearest insertion preserves the existing <= tie order and wrapping arithmetic.

Five alternating measured process pairs after a discarded warm pair show complete Overworld generation plus decoration improving by median paired 4.15% / 2.38% at the primary site with one/four workers, and 3.87% / 3.28% at a second site. All 20 affected pairs improve. Non-warmed generation improves 2.18%; Nether/End changes remain within noise. These are complete batch wall-time measurements, not isolated aquifer timings. Reproduce with chunkgen_bench RESOURCES --seed 12345 --size 16 --threads 1 --warmup --json --no-map and repeat with four workers.

The fixed inline cache adds 312 bytes per transient aquifer object, no allocation calls, and about 3.8 KiB of executable text. Four-worker peak RSS medians differ by about 0.4%, with paired results spanning both directions. Saved/resident chunks are unchanged. Streaming fill improves slightly; flight update p99 differs by +0.008 ms, with matching output counts and no nearby unlit frames.

The generation benchmark options are the same small tooling change also present in #1223. This PR contains the aquifer optimization independently; it does not include the saved-palette optimization or depend on it.

Vanilla reference

Pinned 26.3 Aquifer.NoiseBasedAquifer.computeSubstance: retain cell traversal, later-cell distance ties, random draws, sampler/error order, existing cache effects and fluid-update scheduling.

Validation:

  • Fresh authenticated client/server aquifer oracle: 379 fixtures / 389,804 matching lines per JAR, including all 18 injected failure/retry cases.
  • Terrain-fill oracle: 114 fixtures, 200 fills / 7,950,873 matching lines per JAR.
  • Material/carver oracle: 79 fixtures / 6,733,382 matching lines per JAR.
  • 36 exact pre/post-decoration comparisons across three dimensions, three seeds/sites (including negative and near-world-border coordinates), and one/four workers. Blocks, biomes, all heightmaps, ordered postprocessing, structures, entities, ticks and chunk metadata match.
  • Final production rebuild is byte-identical to the timed candidate.

These gates cover the declared cases; they do not prove every possible world or gameplay state.

Self-check

The combined campaign working tree (this aquifer code and the separately proposed saved-palette code) passed the required quick self-check: public-tree validation, workspace formatting, Clippy with warnings denied, 1,442 client/core/world tests, and doc tests. The full self-check output follows; the three fresh affected oracle suites above were run separately. The standalone PR is independently based on current upstream main.

pr_ready (tools/pr_ready.py --quick on archlinux, against origin/main at 41055168a, 4 min 23 s)

Check Result
Scope ✅ 6 files, +590 −55
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (5 s)
clippy ✅ (25 s)
tests: horizon-client, horizon-core, horizon-world ✅ 1442 passed (3 min 48 s)
doc tests ✅ 0 passed (2 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 321 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 309 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🔄 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/1229 **Author:** [@rdbtCVS](https://github.com/rdbtCVS) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/aquifer-neighborhood` --- ### 📝 Commits (3) - [`97edfec`](https://github.com/horizon-rust/horizon/commit/97edfec91491825e44c10d8bb754347b95daa146) perf: reuse decoded aquifer neighborhoods during terrain fill - [`a648622`](https://github.com/horizon-rust/horizon/commit/a648622b9232023b106c6b1eb4f26b46b1f5fb6f) bench: report exact warmed generation wall timings - [`b054c8d`](https://github.com/horizon-rust/horizon/commit/b054c8db1156c63e5c97584d01897ef7c3730609) Remove benchmark report from pull request ### 📊 Changes **2 files changed** (+105 additions, -39 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-world/examples/chunkgen_bench.rs` (+37 -1) 📝 `crates/horizon-world/src/worldgen/aquifer/noise_based.rs` (+68 -38) </details> ### 📄 Description ## What and why Aquifer samples repeatedly check and unpack the same twelve neighboring cell positions as terrain filling walks a grid cell. Cache that decoded neighborhood until the grid key changes, publishing a replacement only after every checked access succeeds. Explicit four-slot nearest insertion preserves the existing `<=` tie order and wrapping arithmetic. Five alternating measured process pairs after a discarded warm pair show complete Overworld generation plus decoration improving by median paired **4.15% / 2.38%** at the primary site with one/four workers, and **3.87% / 3.28%** at a second site. All 20 affected pairs improve. Non-warmed generation improves 2.18%; Nether/End changes remain within noise. These are complete batch wall-time measurements, not isolated aquifer timings. Reproduce with `chunkgen_bench RESOURCES --seed 12345 --size 16 --threads 1 --warmup --json --no-map` and repeat with four workers. The fixed inline cache adds **312 bytes per transient aquifer object**, no allocation calls, and about 3.8 KiB of executable text. Four-worker peak RSS medians differ by about 0.4%, with paired results spanning both directions. Saved/resident chunks are unchanged. Streaming fill improves slightly; flight update p99 differs by +0.008 ms, with matching output counts and no nearby unlit frames. The generation benchmark options are the same small tooling change also present in #1223. This PR contains the aquifer optimization independently; it does not include the saved-palette optimization or depend on it. ## Vanilla reference Pinned 26.3 `Aquifer.NoiseBasedAquifer.computeSubstance`: retain cell traversal, later-cell distance ties, random draws, sampler/error order, existing cache effects and fluid-update scheduling. Validation: - Fresh authenticated client/server aquifer oracle: 379 fixtures / 389,804 matching lines per JAR, including all 18 injected failure/retry cases. - Terrain-fill oracle: 114 fixtures, 200 fills / 7,950,873 matching lines per JAR. - Material/carver oracle: 79 fixtures / 6,733,382 matching lines per JAR. - 36 exact pre/post-decoration comparisons across three dimensions, three seeds/sites (including negative and near-world-border coordinates), and one/four workers. Blocks, biomes, all heightmaps, ordered postprocessing, structures, entities, ticks and chunk metadata match. - Final production rebuild is byte-identical to the timed candidate. These gates cover the declared cases; they do not prove every possible world or gameplay state. ## Self-check The combined campaign working tree (this aquifer code and the separately proposed saved-palette code) passed the required quick self-check: public-tree validation, workspace formatting, Clippy with warnings denied, **1,442 client/core/world tests**, and doc tests. The full self-check output follows; the three fresh affected oracle suites above were run separately. The standalone PR is independently based on current upstream main. **pr_ready** (`tools/pr_ready.py --quick` on archlinux, against origin/main at 41055168a, 4 min 23 s) | Check | Result | | --- | --- | | Scope | ✅ 6 files, +590 −55 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (5 s) | | clippy | ✅ (25 s) | | tests: horizon-client, horizon-core, horizon-world | ✅ 1442 passed (3 min 48 s) | | doc tests | ✅ 0 passed (2 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 321 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 309 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:09:31 +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#3435
No description provided.