[PR #6827] [MERGED] Single player: the window shares the server thread's sections #7120

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

📋 Pull Request Information

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

Base: main ← Head: perf/share-sections


📝 Commits (1)

  • fd73f00 Single player: the window shares the server thread's sections

📊 Changes

7 files changed (+205 additions, -5 deletions)

View changed files

📝 crates/horizon-client-render/src/chunk.rs (+6 -0)
📝 crates/horizon-client/src/game/memory.rs (+42 -3)
📝 crates/horizon-client/src/game/remote_chunks.rs (+3 -0)
➕ crates/horizon-client/src/lan/handoff.rs (+132 -0)
📝 crates/horizon-client/src/lan/hub.rs (+6 -0)
📝 crates/horizon-client/src/lan/mod.rs (+1 -0)
📝 crates/horizon-core/src/paletted.rs (+15 -2)

📄 Description

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

Stacked on #6826.

What

In single player, the server thread and its window each held every column that both of them see: the server its level, the window what the chunk packets decoded to. That is two copies of the same blocks, biomes and light.

When the server sends a column on its in-memory connection, it now offers the column's sections as Weak references (lan/handoff.rs). After decoding the packet, the window takes each offered section that is equal to the one it decoded, and drops its own copy.

  • What either side sees doesn't change. The packet is still sent and decoded, and a section is taken only when its blocks, biomes and light all equal the decoded ones.
  • An edit on either side copies the section for that side only (Arc::make_mut, already how sections are written).
  • A Weak keeps nothing alive, and stale offers are swept.
  • Only the memory connection offers: LAN guests and dedicated servers are untouched.

PalettedContainer equality now compares the layout first: same palette, bit width and words means equal, without decoding 4,096 entries.

horizon-ctl memory reports shared_with_server: the window's sections that the server's levels also hold.

A/B

playhorizon (Linux, 8 vCPU shared with other jobs, load 14-29), headless single player on the server thread, seed 1234, creative. Three rounds, each running the variants side by side; medians, and the direction of each round's pair. At RD 32 the window settled at 3,725 columns and the server at 4,761. Base: #6826.

before after Δ rounds
RSS, RD 16 665 MB 637 MB −28 MB 3/3 down
RSS, RD 32 976 MB 858 MB −118 MB 3/3 down (one by 3 MB)
peak RSS, RD 32 1,010 MB 867 MB −143 MB 3/3 down
allocator committed, RD 32 1,111 MB 1,051 MB −60 MB
window's sections shared with the server, RD 16 - 25.3 of 34.3 MB
window's sections shared with the server, RD 32 - 97.0 of 115.9 MB (43,615 sections)

84 % of the window's column bytes at RD 32 are now the server's own sections. The rest are columns the server no longer holds, or ones that were edited.

Checks

pr_ready --quick on playhorizon, run on the top of the stack (#6827, which contains this branch).

Check Result
Scope ⚠️ 21 files, +632 −132; 763 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅ (1 s)
Python tests ❌ 598 run, FAILED (failures=2, skipped=1) (2 min 54 s)
rustfmt ✅ (1 min 15 s)
clippy ✅ (9 min 19 s)
tests: horizon-client, horizon-client-lib, horizon-client-render, horizon-core, horizon-threads ✅ 3054 passed (45 min 27 s)
doc tests ✅ 0 passed (7 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 ➖ 146 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 134 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)
  • Python tests: test_lab.GameEnvScreenTests fails twice because the host's runner environment sets VSCREEN. This stack touches no Python.
  • Parity: left to CI's parity job.

The pr_ready block above ran on adaeb5141e, before the stack was rebased onto main. On the rebased head, cargo check of the client and client lib (bins and tests) passes; see #6826 for the mesher change the rebase needed.

🤖 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/6827 **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/share-sections` --- ### 📝 Commits (1) - [`fd73f00`](https://github.com/horizon-rust/horizon/commit/fd73f00940dfefe3774cee01eb243c96aed03214) Single player: the window shares the server thread's sections ### 📊 Changes **7 files changed** (+205 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/chunk.rs` (+6 -0) 📝 `crates/horizon-client/src/game/memory.rs` (+42 -3) 📝 `crates/horizon-client/src/game/remote_chunks.rs` (+3 -0) ➕ `crates/horizon-client/src/lan/handoff.rs` (+132 -0) 📝 `crates/horizon-client/src/lan/hub.rs` (+6 -0) 📝 `crates/horizon-client/src/lan/mod.rs` (+1 -0) 📝 `crates/horizon-core/src/paletted.rs` (+15 -2) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Stacked on #6826. ## What In single player, the server thread and its window each held every column that both of them see: the server its level, the window what the chunk packets decoded to. That is two copies of the same blocks, biomes and light. When the server sends a column on its in-memory connection, it now offers the column's sections as `Weak` references (`lan/handoff.rs`). After decoding the packet, the window takes each offered section that is equal to the one it decoded, and drops its own copy. - What either side sees doesn't change. The packet is still sent and decoded, and a section is taken only when its blocks, biomes and light all equal the decoded ones. - An edit on either side copies the section for that side only (`Arc::make_mut`, already how sections are written). - A `Weak` keeps nothing alive, and stale offers are swept. - Only the memory connection offers: LAN guests and dedicated servers are untouched. `PalettedContainer` equality now compares the layout first: same palette, bit width and words means equal, without decoding 4,096 entries. `horizon-ctl memory` reports `shared_with_server`: the window's sections that the server's levels also hold. ## A/B playhorizon (Linux, 8 vCPU shared with other jobs, load 14-29), headless single player on the server thread, seed 1234, creative. Three rounds, each running the variants side by side; medians, and the direction of each round's pair. At RD 32 the window settled at 3,725 columns and the server at 4,761. Base: #6826. | | before | after | Δ | rounds | |---|---|---|---|---| | RSS, RD 16 | 665 MB | 637 MB | **−28 MB** | 3/3 down | | RSS, RD 32 | 976 MB | 858 MB | **−118 MB** | 3/3 down (one by 3 MB) | | peak RSS, RD 32 | 1,010 MB | 867 MB | −143 MB | 3/3 down | | allocator committed, RD 32 | 1,111 MB | 1,051 MB | −60 MB | | | window's sections shared with the server, RD 16 | - | 25.3 of 34.3 MB | | | | window's sections shared with the server, RD 32 | - | 97.0 of 115.9 MB (43,615 sections) | | | 84 % of the window's column bytes at RD 32 are now the server's own sections. The rest are columns the server no longer holds, or ones that were edited. ## Checks `pr_ready --quick` on playhorizon, run on the top of the stack (#6827, which contains this branch). | Check | Result | | --- | --- | | Scope | ⚠️ 21 files, +632 −132; 763 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ (1 s) | | Python tests | ❌ 598 run, FAILED (failures=2, skipped=1) (2 min 54 s) | | rustfmt | ✅ (1 min 15 s) | | clippy | ✅ (9 min 19 s) | | tests: horizon-client, horizon-client-lib, horizon-client-render, horizon-core, horizon-threads | ✅ 3054 passed (45 min 27 s) | | doc tests | ✅ 0 passed (7 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 | ➖ 146 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 134 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | - **Python tests**: `test_lab.GameEnvScreenTests` fails twice because the host's runner environment sets `VSCREEN`. This stack touches no Python. - **Parity**: left to CI's parity job. The pr_ready block above ran on adaeb5141e, before the stack was rebased onto main. On the rebased head, `cargo check` of the client and client lib (bins and tests) passes; see #6826 for the mesher change the rebase needed. 🤖 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:34:14 +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#7120
No description provided.