[PR #824] [MERGED] Clients keep the light the server sends; the server sends light updates #2835

Closed
opened 2026-11-02 15:59:26 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: perf/chunk-light-sync


📝 Commits (1)

  • 817a71f Clients keep the light the server sends; the server sends light updates

📊 Changes

13 files changed (+394 additions, -32 deletions)

View changed files

📝 crates/horizon-client/src/bin/horizon-ctl/commands.rs (+4 -0)
📝 crates/horizon-client/src/game.rs (+1 -0)
📝 crates/horizon-client/src/game/agent.rs (+37 -1)
📝 crates/horizon-client/src/game/lan.rs (+2 -0)
📝 crates/horizon-client/src/game/remote.rs (+60 -0)
📝 crates/horizon-client/src/lan/chunks.rs (+27 -0)
📝 crates/horizon-client/src/lan/hub.rs (+41 -0)
📝 crates/horizon-client/src/light.rs (+113 -0)
📝 crates/horizon-client/src/save.rs (+2 -25)
📝 crates/horizon-client/src/streaming.rs (+30 -3)
📝 crates/horizon-client/src/world.rs (+5 -0)
📝 docs/native-client.md (+1 -1)
📝 tools/lan_e2e.py (+71 -2)

📄 Description

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

What

A remote client (a LAN guest, or the game itself when single player runs on its server thread) now keeps the light the server sends, and the server sends light updates.

  • Client: no relight of received chunks. LevelChunkWithLight carries the column's sky and block light. The client threw it away and relit the column and its 8 neighbours. Now it applies the layers as ClientPacketListener.applyLightData / readSectionList do:

    • a section in the mask takes its layer, one in the empty mask is dark;
    • a section with no sky layer repeats the bottom row of the nearest layer above it, open sky above the highest (SkyLightSectionStorage.getLightValue);
    • a section with no block layer is dark.

    The column and its neighbours remesh (enableChunkLight). Block changes are still relit on the client, as vanilla's client does.

  • Client: ClientboundLightUpdatePacket. The sections it names take its sky and block layers (queueSectionData), and those sections and their neighbours remesh.

  • Server: light updates. The hub logs the light sections that change in each column (ChunkHolder.sectionLightChanged). Each tick, before the block changes, it sends them to the players for whom that column is on the border of what they track (broadcastChanges, isChunkOnTrackedBorder). Players deeper in light the block changes they are sent themselves, as in vanilla.

  • save::load_light and the client share the layer-to-light code (light::light_from_layers).

  • horizon-ctl light X1 Y1 Z1 X2 Y2 Z2 reads the stored light of a box. lan_e2e has a new light check that uses it.

Differences from vanilla's packets (the client ends with the same light either way):

  • Horizon's light engine doesn't tell sky and block changes apart, so a changed section sends both layers.
  • A section whose layer went away as its last block was removed is still sent. Otherwise a guest that doesn't track that block would keep its old light. The new check covers this case.

Measured (Mac mini M4 Pro, shared with other sessions)

Method:

  • Single player with --server-thread --offscreen, RD 12, fresh world, seed 1234, creative.
  • 40 s after launch, the player travels 450 blocks in 15 s (/tp 15 blocks every 0.5 s).
  • macOS sample records the whole process during that travel (1 ms samples). CPU is the process's CPU time over the travel.
  • Main is 9f7bd911. Runs in the order main / this / main / this / main.
build process CPU over the travel light_chunk samples (all workers, server and client)
main 37.2 / 31.1 / 29.9 s 7811 / 8891 / 9827
this 24.2 / 30.3 s 6895 / 4633
  • Means: CPU 32.7 → 27.3 s (−17 %); light jobs 8843 → 5764 samples (−35 %). What remains is the server lighting the chunks it generates.
  • The client runs no light jobs any more: no full relight of a column on arrival, and none for its neighbours.
  • A LAN guest gains the same.

Checks

  • cargo fmt --all --check and cargo clippy --workspace --all-targets -- -D warnings: clean.
  • cargo test -p horizon-client --lib: 854 passed. A new unit test covers the layers-to-light rules and light updates.
  • tools/parity.py --changed origin/main: 90 of 91 pass, including light, lan, dedicated_server, save_roundtrip, world_reopen and block_entity_tickers.
    • tooltip_display fails. It is broken on main too: the harness writes Python's True/False and the fixture parses them as Rust bool, so it stops at ParseBoolError. Nothing here touches tooltips.
  • lan_e2e --check light passes, with and without --server-thread. Positions compared, all equal:
    • 4205 around a torch the host places by the guest;
    • 1183 under a stone roof, and 1183 again once a block of the roof is removed under the sky;
    • 1904 in the guest's last tracked chunk next to glowstone in a chunk it doesn't track, and again after the glowstone is removed. Only light update packets can bring this.
  • lan_e2e tab, self, armour, nametags, walls, chest, crafting, sign, damage, mobs, pvp, containers, feedback, recipes, trials, clicks, sleep, push, eat, xp and effects pass. --server-thread portals passes.
    • hazards leaves the guest dead in the void, and the checks after it fail. Main's build does the same.
    • commands fails on /bossbar get completion. #809 fixes that on main, and this build predates it.

Needs Ludovic

Nothing.

🤖 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/824 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/18/2026 **Status:** ✅ Merged **Merged:** 10/18/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/chunk-light-sync` --- ### 📝 Commits (1) - [`817a71f`](https://github.com/horizon-rust/horizon/commit/817a71ffa5c57fada9ee5a19a7f4e751486df187) Clients keep the light the server sends; the server sends light updates ### 📊 Changes **13 files changed** (+394 additions, -32 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/bin/horizon-ctl/commands.rs` (+4 -0) 📝 `crates/horizon-client/src/game.rs` (+1 -0) 📝 `crates/horizon-client/src/game/agent.rs` (+37 -1) 📝 `crates/horizon-client/src/game/lan.rs` (+2 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+60 -0) 📝 `crates/horizon-client/src/lan/chunks.rs` (+27 -0) 📝 `crates/horizon-client/src/lan/hub.rs` (+41 -0) 📝 `crates/horizon-client/src/light.rs` (+113 -0) 📝 `crates/horizon-client/src/save.rs` (+2 -25) 📝 `crates/horizon-client/src/streaming.rs` (+30 -3) 📝 `crates/horizon-client/src/world.rs` (+5 -0) 📝 `docs/native-client.md` (+1 -1) 📝 `tools/lan_e2e.py` (+71 -2) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What A remote client (a LAN guest, or the game itself when single player runs on its server thread) now keeps the light the server sends, and the server sends light updates. - **Client: no relight of received chunks.** `LevelChunkWithLight` carries the column's sky and block light. The client threw it away and relit the column and its 8 neighbours. Now it applies the layers as `ClientPacketListener.applyLightData` / `readSectionList` do: - a section in the mask takes its layer, one in the empty mask is dark; - a section with no sky layer repeats the bottom row of the nearest layer above it, open sky above the highest (`SkyLightSectionStorage.getLightValue`); - a section with no block layer is dark. The column and its neighbours remesh (`enableChunkLight`). Block changes are still relit on the client, as vanilla's client does. - **Client: `ClientboundLightUpdatePacket`.** The sections it names take its sky and block layers (`queueSectionData`), and those sections and their neighbours remesh. - **Server: light updates.** The hub logs the light sections that change in each column (`ChunkHolder.sectionLightChanged`). Each tick, before the block changes, it sends them to the players for whom that column is on the border of what they track (`broadcastChanges`, `isChunkOnTrackedBorder`). Players deeper in light the block changes they are sent themselves, as in vanilla. - `save::load_light` and the client share the layer-to-light code (`light::light_from_layers`). - `horizon-ctl light X1 Y1 Z1 X2 Y2 Z2` reads the stored light of a box. `lan_e2e` has a new `light` check that uses it. Differences from vanilla's packets (the client ends with the same light either way): - Horizon's light engine doesn't tell sky and block changes apart, so a changed section sends both layers. - A section whose layer went away as its last block was removed is still sent. Otherwise a guest that doesn't track that block would keep its old light. The new check covers this case. ## Measured (Mac mini M4 Pro, shared with other sessions) Method: - Single player with `--server-thread --offscreen`, RD 12, fresh world, seed 1234, creative. - 40 s after launch, the player travels 450 blocks in 15 s (`/tp` 15 blocks every 0.5 s). - macOS `sample` records the whole process during that travel (1 ms samples). CPU is the process's CPU time over the travel. - Main is 9f7bd911. Runs in the order main / this / main / this / main. | build | process CPU over the travel | `light_chunk` samples (all workers, server and client) | |---|---|---| | main | 37.2 / 31.1 / 29.9 s | 7811 / 8891 / 9827 | | **this** | **24.2 / 30.3 s** | **6895 / 4633** | - Means: CPU 32.7 → 27.3 s (−17 %); light jobs 8843 → 5764 samples (−35 %). What remains is the server lighting the chunks it generates. - The client runs no light jobs any more: no full relight of a column on arrival, and none for its neighbours. - A LAN guest gains the same. ## Checks - `cargo fmt --all --check` and `cargo clippy --workspace --all-targets -- -D warnings`: clean. - `cargo test -p horizon-client --lib`: 854 passed. A new unit test covers the layers-to-light rules and light updates. - `tools/parity.py --changed origin/main`: 90 of 91 pass, including `light`, `lan`, `dedicated_server`, `save_roundtrip`, `world_reopen` and `block_entity_tickers`. - `tooltip_display` fails. It is broken on main too: the harness writes Python's `True`/`False` and the fixture parses them as Rust `bool`, so it stops at `ParseBoolError`. Nothing here touches tooltips. - `lan_e2e --check light` passes, with and without `--server-thread`. Positions compared, all equal: - 4205 around a torch the host places by the guest; - 1183 under a stone roof, and 1183 again once a block of the roof is removed under the sky; - 1904 in the guest's last tracked chunk next to glowstone in a chunk it doesn't track, and again after the glowstone is removed. Only light update packets can bring this. - `lan_e2e` tab, self, armour, nametags, walls, chest, crafting, sign, damage, mobs, pvp, containers, feedback, recipes, trials, clicks, sleep, push, eat, xp and effects pass. `--server-thread` portals passes. - `hazards` leaves the guest dead in the void, and the checks after it fail. Main's build does the same. - `commands` fails on `/bossbar get` completion. #809 fixes that on main, and this build predates it. ## Needs Ludovic Nothing. 🤖 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-02 15:59:26 +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#2835
No description provided.