[PR #1201] [MERGED] Server tick: cheaper view requeue, chunk ticket levels and player-proximity grid #3417

Closed
opened 2026-11-03 04:09:22 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: claude/upstream-chunk-bookkeeping


📝 Commits (3)

  • da314fa Server tick: cheaper view requeue and chunk ticket levels
  • 9019d70 Streaming: answer "near a player?" from a grid of the players' squares
  • 86e0807 streaming: bound ExtraCover's z range too

📊 Changes

3 files changed (+560 additions, -22 deletions)

View changed files

📝 crates/horizon-client/src/lan/hub.rs (+98 -14)
📝 crates/horizon-client/src/streaming.rs (+238 -0)
📝 crates/horizon-client/src/ticket_levels.rs (+224 -8)

📄 Description

Requested by JR

What and why

Fixes #1219.

Server tick: cheaper view requeue and chunk ticket levels

Two costs that grow with players on the server thread:

  • Hub::update_view rebuilt a player's chunk queue on every chunk crossing
    by scanning the queue (a Vec) once for each chunk of the view. It now
    checks a set. Same queue, same order (differential test against the old
scan). 111 -> 16 us per crossing at view 10, 6.5 ms -> 0.13 ms at 32.
  • ChunkTickets rebuilt a hash map of every ticketed chunk whenever any
    player changed chunk, and every block entity, mob and ticking chunk
    hashed into it. Levels are now a grid over the tickets' bounding box,
with the map kept for tickets spread too far apart. At 50 players:
build 0.23 -> 0.08 ms, lookups about 2x faster (differential test over
200 random ticket layouts).

Streaming: answer "near a player?" from a grid of the players' squares

On a server every player is an extra area, and streaming asks of every
loaded and wanted column, several times a tick (unloading, dropping
protos, finishing, decoration, the generation scan), whether one of
those squares reaches it: a scan of every player's square per question.
The squares are now one grid of distances, made again when a player
changes chunk, and in_extra reads it. Differential test against the scan
over 60 random layouts, every margin.

At 50 players, 6081 columns, 3 questions each: 0.45 ms -> 0.04 ms, plus
0.02 ms to make the grid.

Vanilla reference

Ticket levels follow DistanceManager and TicketType as before; the view requeue is Horizon's LAN hub and the player-area check is Horizon's streaming, both Horizon-only. Behaviour is unchanged: differential tests in this PR compare the new code with the old scans (queue order, 200 random ticket layouts, 60 random player layouts). Harness: test_chunk_status_parity.py.

Self-check

pr_ready (tools/pr_ready.py --base upstream/main on Mac, against upstream/main at fd0473605, 1 min 50 s)

Check Result
Scope ⚠️ 3 files, +557 −22; 579 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅ (1 s)
Python tests ➖ no Python change
rustfmt ✅ (4 s)
clippy ✅ (26 s)
tests: horizon-client ✅ 1085 passed (1 min 12 s)
doc tests ✅ 0 passed (7 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses
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/1201 **Author:** [@pirut](https://github.com/pirut) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `claude/upstream-chunk-bookkeeping` --- ### 📝 Commits (3) - [`da314fa`](https://github.com/horizon-rust/horizon/commit/da314fa658e9b07b0e1c8d5552a126bbeb9c7bc2) Server tick: cheaper view requeue and chunk ticket levels - [`9019d70`](https://github.com/horizon-rust/horizon/commit/9019d708d0b49df09945213fe6e33246aa8b2dc0) Streaming: answer "near a player?" from a grid of the players' squares - [`86e0807`](https://github.com/horizon-rust/horizon/commit/86e08072e44651634a581e20a689ceaf34e46601) streaming: bound ExtraCover's z range too ### 📊 Changes **3 files changed** (+560 additions, -22 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/lan/hub.rs` (+98 -14) 📝 `crates/horizon-client/src/streaming.rs` (+238 -0) 📝 `crates/horizon-client/src/ticket_levels.rs` (+224 -8) </details> ### 📄 Description <!-- claude-projects-attribution: {"github_login":"pirut"} --> _Requested by **JR**_ ## What and why Fixes #1219. Server tick: cheaper view requeue and chunk ticket levels Two costs that grow with players on the server thread: - Hub::update_view rebuilt a player's chunk queue on every chunk crossing by scanning the queue (a Vec) once for each chunk of the view. It now checks a set. Same queue, same order (differential test against the old ``` scan). 111 -> 16 us per crossing at view 10, 6.5 ms -> 0.13 ms at 32. ``` - ChunkTickets rebuilt a hash map of every ticketed chunk whenever any player changed chunk, and every block entity, mob and ticking chunk hashed into it. Levels are now a grid over the tickets' bounding box, ``` with the map kept for tickets spread too far apart. At 50 players: build 0.23 -> 0.08 ms, lookups about 2x faster (differential test over 200 random ticket layouts). ``` Streaming: answer "near a player?" from a grid of the players' squares On a server every player is an extra area, and streaming asks of every loaded and wanted column, several times a tick (unloading, dropping protos, finishing, decoration, the generation scan), whether one of those squares reaches it: a scan of every player's square per question. The squares are now one grid of distances, made again when a player changes chunk, and in_extra reads it. Differential test against the scan over 60 random layouts, every margin. At 50 players, 6081 columns, 3 questions each: 0.45 ms -> 0.04 ms, plus 0.02 ms to make the grid. ## Vanilla reference Ticket levels follow `DistanceManager` and `TicketType` as before; the view requeue is Horizon's LAN hub and the player-area check is Horizon's streaming, both Horizon-only. Behaviour is unchanged: differential tests in this PR compare the new code with the old scans (queue order, 200 random ticket layouts, 60 random player layouts). Harness: `test_chunk_status_parity.py`. ## Self-check **pr_ready** (`tools/pr_ready.py --base upstream/main` on Mac, against upstream/main at fd0473605, 1 min 50 s) | Check | Result | | --- | --- | | Scope | ⚠️ 3 files, +557 −22; 579 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ (1 s) | | Python tests | ➖ no Python change | | rustfmt | ✅ (4 s) | | clippy | ✅ (26 s) | | tests: horizon-client | ✅ 1085 passed (1 min 12 s) | | doc tests | ✅ 0 passed (7 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses | | 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 04:09:22 +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#3417
No description provided.