[PR #4320] [MERGED] Send a column once its neighbours reach INITIALIZE_LIGHT (#4294) #5558

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

📋 Pull Request Information

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

Base: main ← Head: fix/light-edge-neighbours


📝 Commits (3)

  • d24853c Send a column once its neighbours reach INITIALIZE_LIGHT (#4294)
  • 7fb48c7 Merge remote-tracking branch 'origin/main' into fix/light-edge-neighbours
  • b32541c Map proto sections through the column layout

📊 Changes

11 files changed (+161 additions, -7 deletions)

View changed files

📝 crates/horizon-client-render/src/streaming.rs (+22 -0)
📝 crates/horizon-client/src/game/lan.rs (+2 -0)
📝 crates/horizon-client/src/game/lan_actions.rs (+1 -0)
📝 crates/horizon-client/src/game/server_travel.rs (+1 -0)
📝 crates/horizon-client/src/lan/chunks.rs (+63 -4)
📝 crates/horizon-client/src/lan/hub.rs (+30 -3)
📝 crates/horizon-client/src/save.rs (+6 -0)
📝 crates/horizon-client/src/vanillagen.rs (+18 -0)
📝 crates/horizon-client/tests/forced_chunks.rs (+12 -0)
📝 crates/horizon-client/tests/lan_bot.rs (+1 -0)
📝 crates/horizon-world/src/worldgen/terrain.rs (+5 -0)

📄 Description

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

Fixes #4294. Part of the server plan #3989.

What was wrong

dedicated_server failed on the play-light-layers line on four unrelated PRs today, on both runners. On playhorizon, it failed 5 of 5 on main.

For two chunks at the edge of the first view (7,-2 and 7,-3), vanilla sends light layers for sections 0 to 16 and Horizon for 0 to 15. The missing section 16 is there because a neighbour, 8,-3, has blocks in section 15.

A trace of each chunk sent showed the cause. 7,-2 and 7,-3 load from the save with their light already made, so no light job runs for them. The hub sent them as soon as they were lit, while 8,-3 (and, for 7,-3, the row at z = -4) was still a proto chunk being made. ChunkEncoder::around built the light-section mask from loaded columns only, so 8,-3's blocks didn't count.

Vanilla can't send a chunk that early. ChunkStatus.LIGHT needs every neighbour at INITIALIZE_LIGHT (in the loading pyramid too), and its light storage counts the sections of those neighbours, proto chunks included. This shows since #4095: an idle dedicated server keeps no spawn area, so the area around a joining player now loads and lights while its first chunks go out.

The fix

  • Hub (next_batch): a lit column is sent once each of its eight neighbours is loaded or a decorated proto chunk (Horizon's FEATURES, which comes before INITIALIZE_LIGHT).
  • Encoder (around): a neighbour that is still a proto chunk counts with its non-air sections. They are read when the column is sent (Streaming::proto_sections), from the counters TerrainChunk already keeps per section, through a new ChunkGenerator::non_air_sections.
  • Nothing is kept per column.
  • TickCtx gets the level's Streaming. A test hub without one (None) sends as before.

Measured on playhorizon (CPUs 0-3, exclusive)

dedicated_server: main 483d832a3 failed 5 of 5; this branch passes 5 of 5.

Idle dedicated server, RSS 10 s after the first status ping, 3 interleaved rounds:

round 1 round 2 round 3
main 483d832a3 334 MB 330 MB 330 MB
this PR 333 MB 334 MB 330 MB

No change; ready time ~3.8 s both.

Holding a column back until its neighbours are decorated could slow the first screen of chunks, so that was measured too. 30 idle bots join a fresh world every 0.5 s (view distance 10, sn_run.py). "First view" is the time from asking to join to the last chunk new to the bot (view_after_ms, added to horizon-bots on tools/bots-view-time). 3 interleaved rounds:

join p99 first view p50 first view p99
main 124 / 100 / 104 ms 3247 / 2746 / 2800 ms 8568 / 7813 / 7907 ms
this PR 100 / 100 / 100 ms 2603 / 2508 / 2701 ms 7556 / 7868 / 7655 ms

Neither got worse; first view is a little faster, within noise.

Tests

  • lan::chunks::a_proto_neighbour_counts_for_the_light_layers: a column next to a proto neighbour gets the same body as when that neighbour is loaded.
  • forced_chunks (integration): proto_sections gives the decorated third ring's sections, and nothing for the fourth ring (terrain only) or for level chunks.
  • lan_bot builds its TickCtx without a streaming.
  • tools/port_ledger.py check was not run: no ledger is built on this machine.

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at 0a341cc35, 9 min 45 s)

Check Result
Scope ✅ 11 files, +161 −7
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 480 passed (1 min 39 s)
rustfmt ✅ (11 s)
clippy ✅ (1 min 34 s)
tests: horizon-client, horizon-client-render, horizon-world ✅ 1831 passed (5 min 51 s)
doc tests ✅ 0 passed (5 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 ➖ 136 affected, to run in CI (--quick): ambient_sound, arrow, attribute_updates, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, block_tint, block_transformer and 124 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 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/4320 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/light-edge-neighbours` --- ### 📝 Commits (3) - [`d24853c`](https://github.com/horizon-rust/horizon/commit/d24853c0a0858b955c5fc8ec7d08e96cd17b7651) Send a column once its neighbours reach INITIALIZE_LIGHT (#4294) - [`7fb48c7`](https://github.com/horizon-rust/horizon/commit/7fb48c715443b8a36d89c4c7480a3970b97ffa6e) Merge remote-tracking branch 'origin/main' into fix/light-edge-neighbours - [`b32541c`](https://github.com/horizon-rust/horizon/commit/b32541cb88dbe43c1544d2ed86024ff524844278) Map proto sections through the column layout ### 📊 Changes **11 files changed** (+161 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/streaming.rs` (+22 -0) 📝 `crates/horizon-client/src/game/lan.rs` (+2 -0) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+1 -0) 📝 `crates/horizon-client/src/game/server_travel.rs` (+1 -0) 📝 `crates/horizon-client/src/lan/chunks.rs` (+63 -4) 📝 `crates/horizon-client/src/lan/hub.rs` (+30 -3) 📝 `crates/horizon-client/src/save.rs` (+6 -0) 📝 `crates/horizon-client/src/vanillagen.rs` (+18 -0) 📝 `crates/horizon-client/tests/forced_chunks.rs` (+12 -0) 📝 `crates/horizon-client/tests/lan_bot.rs` (+1 -0) 📝 `crates/horizon-world/src/worldgen/terrain.rs` (+5 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Fixes #4294. Part of the server plan #3989. ## What was wrong `dedicated_server` failed on the `play-light-layers` line on four unrelated PRs today, on both runners. On playhorizon, it failed 5 of 5 on main. For two chunks at the edge of the first view (7,-2 and 7,-3), vanilla sends light layers for sections 0 to 16 and Horizon for 0 to 15. The missing section 16 is there because a neighbour, 8,-3, has blocks in section 15. A trace of each chunk sent showed the cause. 7,-2 and 7,-3 load from the save with their light already made, so no light job runs for them. The hub sent them as soon as they were lit, while 8,-3 (and, for 7,-3, the row at z = -4) was still a proto chunk being made. `ChunkEncoder::around` built the light-section mask from loaded columns only, so 8,-3's blocks didn't count. Vanilla can't send a chunk that early. `ChunkStatus.LIGHT` needs every neighbour at INITIALIZE_LIGHT (in the loading pyramid too), and its light storage counts the sections of those neighbours, proto chunks included. This shows since #4095: an idle dedicated server keeps no spawn area, so the area around a joining player now loads and lights while its first chunks go out. ## The fix - **Hub** (`next_batch`): a lit column is sent once each of its eight neighbours is loaded or a decorated proto chunk (Horizon's FEATURES, which comes before INITIALIZE_LIGHT). - **Encoder** (`around`): a neighbour that is still a proto chunk counts with its non-air sections. They are read when the column is sent (`Streaming::proto_sections`), from the counters `TerrainChunk` already keeps per section, through a new `ChunkGenerator::non_air_sections`. - Nothing is kept per column. - `TickCtx` gets the level's `Streaming`. A test hub without one (`None`) sends as before. ## Measured on playhorizon (CPUs 0-3, exclusive) `dedicated_server`: main 483d832a3 failed 5 of 5; this branch passes 5 of 5. Idle dedicated server, RSS 10 s after the first status ping, 3 interleaved rounds: | | round 1 | round 2 | round 3 | |---|---|---|---| | main 483d832a3 | 334 MB | 330 MB | 330 MB | | this PR | 333 MB | 334 MB | 330 MB | No change; ready time ~3.8 s both. Holding a column back until its neighbours are decorated could slow the first screen of chunks, so that was measured too. 30 idle bots join a fresh world every 0.5 s (view distance 10, `sn_run.py`). "First view" is the time from asking to join to the last chunk new to the bot (`view_after_ms`, added to horizon-bots on `tools/bots-view-time`). 3 interleaved rounds: | | join p99 | first view p50 | first view p99 | |---|---|---|---| | main | 124 / 100 / 104 ms | 3247 / 2746 / 2800 ms | 8568 / 7813 / 7907 ms | | this PR | 100 / 100 / 100 ms | 2603 / 2508 / 2701 ms | 7556 / 7868 / 7655 ms | Neither got worse; first view is a little faster, within noise. ## Tests - `lan::chunks::a_proto_neighbour_counts_for_the_light_layers`: a column next to a proto neighbour gets the same body as when that neighbour is loaded. - `forced_chunks` (integration): `proto_sections` gives the decorated third ring's sections, and nothing for the fourth ring (terrain only) or for level chunks. - `lan_bot` builds its `TickCtx` without a streaming. - `tools/port_ledger.py check` was not run: no ledger is built on this machine. **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at 0a341cc35, 9 min 45 s) | Check | Result | | --- | --- | | Scope | ✅ 11 files, +161 −7 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 480 passed (1 min 39 s) | | rustfmt | ✅ (11 s) | | clippy | ✅ (1 min 34 s) | | tests: horizon-client, horizon-client-render, horizon-world | ✅ 1831 passed (5 min 51 s) | | doc tests | ✅ 0 passed (5 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 | ➖ 136 affected, to run in CI (--quick): ambient_sound, arrow, attribute_updates, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, block_tint, block_transformer and 124 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 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:13:23 +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#5558
No description provided.