[PR #6744] [MERGED] Streaming coordinator: decoration and generation scheduling cost less #7065

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

📋 Pull Request Information

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

Base: main ← Head: perf/gen-coordinator


📝 Commits (1)

  • 912941a Streaming coordinator: decoration and generation scheduling cost less

📊 Changes

2 files changed (+174 additions, -21 deletions)

View changed files

📝 crates/horizon-client-render/src/streaming.rs (+168 -19)
📝 crates/horizon-world/src/worldgen/decoration_order.rs (+6 -2)

📄 Description

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

While a world loads, Streaming::update runs on one thread (the server thread in single player, the frame in-frame) and
schedules every worker. At render distance 32 it was the serial bottleneck of loading on many-core PCs. Profiled with a
generator whose jobs sleep (gen_light_bench --simulate, #6743), so only the pipeline is measured:

  • DecorationOrder::blocked took ~40% of the thread: for every wanted chunk on every update it asked waits_for
    (9 neighbours x 4 set lookups) of 24 neighbours, in a SipHash map.
  • schedule_generation took ~25%: a full scan of every column of the area each time a worker finished.

Changes:

  • decoration ranks in an FxHashMap; waits_for answers kept for the pass (nothing it reads changes in it except
    decorated, whose one write updates the entry);
  • GenerationScan keeps the sorted candidates of its last full scan and takes the next batches from them while the
    ranges are the same and no column left the chunk map (deltas_since only Added); a removal, a dropped proto chunk
    (invalidate), a range change or the end of the plan scans again.

The decoration order and the generation order are unchanged: blocked's rule is the same, and a new differential
test (generation_plan_matches_full_scans_as_columns_arrive) checks every batch against the full scan through 600
random steps (jobs finishing as protos or columns, columns and protos leaving, the centre moving).

Numbers

playhorizon (Linux, 8 vCPU, taskset 0-3, load ~20), gen_light_bench --simulate 13,3,0.4 --radius 32, 3
alternating A/B pairs, same checksum in all runs:

workers coordinator CPU, main this PR wall, main this PR
14 2.00 / 2.26 / 2.17 s 1.55 / 1.39 / 1.52 s (-30%) 4.79 / 4.78 / 4.96 s 4.77 / 4.74 / 4.73 s
32 1.30 / 1.36 / 1.40 s 1.00 / 0.91 / 0.93 s (-32%) 2.18 / 2.18 / 2.19 s 2.20 / 2.17 / 2.17 s

Wall time is bound by the simulated jobs here (the coordinator still had room); what the PR buys is headroom on the
one thread that feeds every worker, which grows with the core count and the render distance. Not measured: real
terrain on a many-core idle machine (both fleet machines were loaded 20-45 tonight).

pr_ready (tools/pr_ready.py --quick on playhorizon, against origin/main at 06f842dc3, 14 min 15 s)

Check Result
Scope ✅ 2 files, +174 −21
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 595 passed (1 min 4 s)
rustfmt ✅ (13 s)
clippy ✅ (1 min 4 s)
tests: horizon-client-render, horizon-world ✅ 1364 passed (10 min 50 s)
doc tests ✅ 0 passed (4 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 ➖ 139 affected, to run in CI (--quick): ambient_sound, armor_stand_frost, arrow, arrow_wind_charge, audio_attributes, auto_jump, blending, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal and 127 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Parity (tools/parity.py on playhorizon at 912941a8f7, the generation harnesses of those it selects; CI runs the rest): 4 passed, 0 failed in 22.4 min: chunk_generation, decoration, server_world_gen, worldgen.

🤖 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/6744 **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-coordinator` --- ### 📝 Commits (1) - [`912941a`](https://github.com/horizon-rust/horizon/commit/912941a8f7b7ea24e4fec3cb36f06e34f5f999c3) Streaming coordinator: decoration and generation scheduling cost less ### 📊 Changes **2 files changed** (+174 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/streaming.rs` (+168 -19) 📝 `crates/horizon-world/src/worldgen/decoration_order.rs` (+6 -2) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. While a world loads, `Streaming::update` runs on one thread (the server thread in single player, the frame in-frame) and schedules every worker. At render distance 32 it was the serial bottleneck of loading on many-core PCs. Profiled with a generator whose jobs sleep (`gen_light_bench --simulate`, #6743), so only the pipeline is measured: - `DecorationOrder::blocked` took ~40% of the thread: for every wanted chunk on every update it asked `waits_for` (9 neighbours x 4 set lookups) of 24 neighbours, in a SipHash map. - `schedule_generation` took ~25%: a full scan of every column of the area each time a worker finished. Changes: - decoration ranks in an `FxHashMap`; `waits_for` answers kept for the pass (nothing it reads changes in it except `decorated`, whose one write updates the entry); - `GenerationScan` keeps the sorted candidates of its last full scan and takes the next batches from them while the ranges are the same and no column left the chunk map (`deltas_since` only `Added`); a removal, a dropped proto chunk (`invalidate`), a range change or the end of the plan scans again. The decoration order and the generation order are unchanged: `blocked`'s rule is the same, and a new differential test (`generation_plan_matches_full_scans_as_columns_arrive`) checks every batch against the full scan through 600 random steps (jobs finishing as protos or columns, columns and protos leaving, the centre moving). ## Numbers playhorizon (Linux, 8 vCPU, `taskset 0-3`, load ~20), `gen_light_bench --simulate 13,3,0.4 --radius 32`, 3 alternating A/B pairs, same checksum in all runs: | workers | coordinator CPU, main | this PR | wall, main | this PR | |---|---|---|---|---| | 14 | 2.00 / 2.26 / 2.17 s | 1.55 / 1.39 / 1.52 s (-30%) | 4.79 / 4.78 / 4.96 s | 4.77 / 4.74 / 4.73 s | | 32 | 1.30 / 1.36 / 1.40 s | 1.00 / 0.91 / 0.93 s (-32%) | 2.18 / 2.18 / 2.19 s | 2.20 / 2.17 / 2.17 s | Wall time is bound by the simulated jobs here (the coordinator still had room); what the PR buys is headroom on the one thread that feeds every worker, which grows with the core count and the render distance. Not measured: real terrain on a many-core idle machine (both fleet machines were loaded 20-45 tonight). **pr_ready** (`tools/pr_ready.py --quick` on playhorizon, against origin/main at 06f842dc3, 14 min 15 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +174 −21 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 595 passed (1 min 4 s) | | rustfmt | ✅ (13 s) | | clippy | ✅ (1 min 4 s) | | tests: horizon-client-render, horizon-world | ✅ 1364 passed (10 min 50 s) | | doc tests | ✅ 0 passed (4 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 | ➖ 139 affected, to run in CI (--quick): ambient_sound, armor_stand_frost, arrow, arrow_wind_charge, audio_attributes, auto_jump, blending, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal and 127 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | **Parity** (`tools/parity.py` on playhorizon at 912941a8f7, the generation harnesses of those it selects; CI runs the rest): 4 passed, 0 failed in 22.4 min: chunk_generation, decoration, server_world_gen, worldgen. 🤖 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 06:33:06 +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#7065
No description provided.