[PR #7519] [MERGED] Generation: empty the shared biome and carver caches when the pool idles #7641

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7519
Author: @ludovic111
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: perf/gen-ring


📝 Commits (1)

  • 1dce4c2 Generation: empty the shared biome and carver caches when the pool idles

📊 Changes

11 files changed (+342 additions, -0 deletions)

View changed files

📝 crates/horizon-client-render/src/streaming.rs (+62 -0)
📝 crates/horizon-client/src/game/memory.rs (+24 -0)
📝 crates/horizon-client/src/save.rs (+9 -0)
📝 crates/horizon-client/src/vanillagen.rs (+18 -0)
📝 crates/horizon-core/src/storage.rs (+4 -0)
📝 crates/horizon-world/src/chunk.rs (+14 -0)
📝 crates/horizon-world/src/heightmap.rs (+4 -0)
📝 crates/horizon-world/src/worldgen/biome_chunk.rs (+4 -0)
📝 crates/horizon-world/src/worldgen/generator.rs (+147 -0)
📝 crates/horizon-world/src/worldgen/generator_structures.rs (+16 -0)
📝 crates/horizon-world/src/worldgen/terrain.rs (+40 -0)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

What

The overworld generator keeps two caches that every worker shares: the biomes of up to 16384 chunks, and the carvers' biome lookups. Each is emptied whole only when it reaches its limit. After a ramp to RD 32 they hold ~33 MB that nothing reads again until the player moves into new ground.

The streaming pool already releases each worker's own caches once every worker has been idle for 5 s (all_idle). It now empties the shared caches at the same point (OverworldGenerator::release_caches). A chunk generated after that comes out the same, because these caches are already emptied whole at their limit. The new test released_caches_generate_the_same_chunks checks it: the blocks and biomes of three chunks (one an ancient city) are equal before and after the release, generated in the opposite order.

horizon-ctl memory gains server_generation, read from the server thread:

  • the proto chunks it holds: bytes by part, and sections by bits per entry;
  • the light views;
  • the generator's caches.

With it the generation ring can be measured without the alloc-census build. This PR found its target that way: at RD 32 the ring is 18 MB of protos, 33 MB of biome cache (released here) and 33 MB of structure starts and templates (bounded and vanilla-like, left alone).

A/B (playhorizon, headless, server thread, seed 1234, alloc-census build, 3 pairs, medians)

A = this branch with the release reverted, B = this branch. "live" = the heap's live bytes (heap_by_tag_mb summed), "biome cache" = server_generation.caches.

A RSS B RSS A live B live A biome cache B biome cache
RD 8 638 MB 646 MB 395 MB 389 MB 5.5 MB 0
RD 32 1007 MB 983 MB 657 MB 625 MB 33.3 MB 0
back to RD 8 852 MB 819 MB 467 MB 433 MB 33.3 MB 0
  • At RD 32 the live heap is down 32 MB and RSS down 24 MB. Back at RD 8 they are down 34 and 33 MB.
  • RSS at RD 8 is within run-to-run noise: A's three runs span 625–646 MB, and B's span 644–655 MB.
  • Time to load RD 32 did not grow: A took 270 / 320 / 165 s, B 240 / 265 / 155 s.
  • Structure starts stay at 33.2 MB in both.

Checks

  • released_caches_generate_the_same_chunks (horizon-world): passes with the vanilla data (HORIZON_RESOURCES, 6 s). Without the data it skips, as in CI.
  • Worldgen harnesses on playhorizon at 1dce4c2bd: all 16 pass (biome_chunk, biome_generation, biome_source, blending, canyon_carver, cave_carver, chunk_generation, feature_graph, generation_tick, noise, retrogen_chunk, server_world_gen, structure_density, structure_layout, structure_start_nbt, worldgen). chunk_generation passed on its retry with fresh oracle results: the reused ones came from an earlier run that the full disk had cut short.
  • Server play, same head: lan_e2e --check chest --check light passes (server-thread host). A dedicated server with 2 walking bots (server_bench) holds 20 TPS, with MSPT averaging 4.86 (p99 8.96).

pr_ready (tools/pr_ready.py --quick on playhorizon, against origin/main at a7621348a, 54 min 2 s)

Check Result
Scope ✅ 11 files, +342 −0
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 614 run, FAILED (failures=2, skipped=1) (1 min 1 s)
rustfmt ✅ (13 s)
clippy ✅ (4 min 22 s)
tests: horizon-client, horizon-client-lib, horizon-client-render, horizon-core, horizon-world ❌ 3768 passed, 6 failed (46 min 58 s)
doc tests ✅ 0 passed (10 s)
content root tests ➖ content root untouched
mod API up to date ✅ (1 min 2 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 245 affected, to run in CI (--quick): ambient_sound, anvil_turtle_egg, armor_stand_frost, armor_stand_turtle_egg, arrow, arrow_wind_charge, attribute_updates, audio_attributes, auto_jump, bamboo, basic_feature, biome_chunk and 233 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)
  • Python tests: test_lab's test_macos_and_windows_start_no_virtual_screen fails because the playhorizon runner's own VSCREEN leaks into it. It fails the same way on main.
  • Tests: the 6 failures are horizon-world's piston tests (pistons_push_and_sticky_pistons_pull, lever_on_piston_back_survives_extend_and_retract…). They fail only when vanilla data is present: on the Mac they fail with HORIZON_RESOURCES set and all 26 pass without it, and CI's verify passes them on this head. This PR does not touch level/.

Label: none (players get less memory used).

🤖 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/7519 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/gen-ring` --- ### 📝 Commits (1) - [`1dce4c2`](https://github.com/horizon-rust/horizon/commit/1dce4c2bd3242cd76cbcc8b8c62112e84087ede3) Generation: empty the shared biome and carver caches when the pool idles ### 📊 Changes **11 files changed** (+342 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/streaming.rs` (+62 -0) 📝 `crates/horizon-client/src/game/memory.rs` (+24 -0) 📝 `crates/horizon-client/src/save.rs` (+9 -0) 📝 `crates/horizon-client/src/vanillagen.rs` (+18 -0) 📝 `crates/horizon-core/src/storage.rs` (+4 -0) 📝 `crates/horizon-world/src/chunk.rs` (+14 -0) 📝 `crates/horizon-world/src/heightmap.rs` (+4 -0) 📝 `crates/horizon-world/src/worldgen/biome_chunk.rs` (+4 -0) 📝 `crates/horizon-world/src/worldgen/generator.rs` (+147 -0) 📝 `crates/horizon-world/src/worldgen/generator_structures.rs` (+16 -0) 📝 `crates/horizon-world/src/worldgen/terrain.rs` (+40 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What The overworld generator keeps two caches that every worker shares: the biomes of up to 16384 chunks, and the carvers' biome lookups. Each is emptied whole only when it reaches its limit. After a ramp to RD 32 they hold ~33 MB that nothing reads again until the player moves into new ground. The streaming pool already releases each worker's own caches once every worker has been idle for 5 s (`all_idle`). It now empties the shared caches at the same point (`OverworldGenerator::release_caches`). A chunk generated after that comes out the same, because these caches are already emptied whole at their limit. The new test `released_caches_generate_the_same_chunks` checks it: the blocks and biomes of three chunks (one an ancient city) are equal before and after the release, generated in the opposite order. `horizon-ctl memory` gains `server_generation`, read from the server thread: - the proto chunks it holds: bytes by part, and sections by bits per entry; - the light views; - the generator's caches. With it the generation ring can be measured without the `alloc-census` build. This PR found its target that way: at RD 32 the ring is 18 MB of protos, 33 MB of biome cache (released here) and 33 MB of structure starts and templates (bounded and vanilla-like, left alone). ## A/B (playhorizon, headless, server thread, seed 1234, `alloc-census` build, 3 pairs, medians) A = this branch with the release reverted, B = this branch. "live" = the heap's live bytes (`heap_by_tag_mb` summed), "biome cache" = `server_generation.caches`. | | A RSS | B RSS | A live | B live | A biome cache | B biome cache | |---|---|---|---|---|---|---| | RD 8 | 638 MB | 646 MB | 395 MB | 389 MB | 5.5 MB | 0 | | RD 32 | 1007 MB | 983 MB | 657 MB | 625 MB | 33.3 MB | 0 | | back to RD 8 | 852 MB | 819 MB | 467 MB | 433 MB | 33.3 MB | 0 | - At RD 32 the live heap is down 32 MB and RSS down 24 MB. Back at RD 8 they are down 34 and 33 MB. - RSS at RD 8 is within run-to-run noise: A's three runs span 625–646 MB, and B's span 644–655 MB. - Time to load RD 32 did not grow: A took 270 / 320 / 165 s, B 240 / 265 / 155 s. - Structure starts stay at 33.2 MB in both. ## Checks - `released_caches_generate_the_same_chunks` (horizon-world): passes with the vanilla data (`HORIZON_RESOURCES`, 6 s). Without the data it skips, as in CI. - Worldgen harnesses on playhorizon at 1dce4c2bd: all 16 pass (biome_chunk, biome_generation, biome_source, blending, canyon_carver, cave_carver, chunk_generation, feature_graph, generation_tick, noise, retrogen_chunk, server_world_gen, structure_density, structure_layout, structure_start_nbt, worldgen). chunk_generation passed on its retry with fresh oracle results: the reused ones came from an earlier run that the full disk had cut short. - Server play, same head: `lan_e2e --check chest --check light` passes (server-thread host). A dedicated server with 2 walking bots (`server_bench`) holds 20 TPS, with MSPT averaging 4.86 (p99 8.96). **pr_ready** (`tools/pr_ready.py --quick` on playhorizon, against origin/main at a7621348a, 54 min 2 s) | Check | Result | | --- | --- | | Scope | ✅ 11 files, +342 −0 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 614 run, FAILED (failures=2, skipped=1) (1 min 1 s) | | rustfmt | ✅ (13 s) | | clippy | ✅ (4 min 22 s) | | tests: horizon-client, horizon-client-lib, horizon-client-render, horizon-core, horizon-world | ❌ 3768 passed, 6 failed (46 min 58 s) | | doc tests | ✅ 0 passed (10 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (1 min 2 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 245 affected, to run in CI (--quick): ambient_sound, anvil_turtle_egg, armor_stand_frost, armor_stand_turtle_egg, arrow, arrow_wind_charge, attribute_updates, audio_attributes, auto_jump, bamboo, basic_feature, biome_chunk and 233 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | - Python tests: `test_lab`'s `test_macos_and_windows_start_no_virtual_screen` fails because the playhorizon runner's own `VSCREEN` leaks into it. It fails the same way on main. - Tests: the 6 failures are horizon-world's piston tests (`pistons_push_and_sticky_pistons_pull`, `lever_on_piston_back_survives_extend_and_retract`…). They fail only when vanilla data is present: on the Mac they fail with `HORIZON_RESOURCES` set and all 26 pass without it, and CI's verify passes them on this head. This PR does not touch `level/`. Label: none (players get less memory used). 🤖 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 07:21:13 +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#7641
No description provided.