[PR #280] [MERGED] Stop reloading saved columns every frame after the player moves #2454

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

📋 Pull Request Information

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

Base: main ← Head: fix/streaming-reload-loop


📝 Commits (1)

  • 0c685d9 Stop reloading saved columns every frame after the player moves

📊 Changes

1 file changed (+67 additions, -17 deletions)

View changed files

📝 crates/horizon-client/src/streaming.rs (+67 -17)

📄 Description

After the player moves far (a teleport, or flying fast), a few saved columns at the edge of the loaded area were loaded from disk, thrown away and loaded again on every frame, forever.

What happened

Three ranges in Streaming::update disagreed:

step range
generation asks for a column view distance + 3, or within 2 of a finished chunk
a column that comes back finished is kept view distance + 2, or within 1 of a finished chunk
a column is unloaded outside view distance + 3 and further than 1 from a finished chunk

A column that had been saved comes back from generator.load already finished. When it fell between the second and first rows, it was dropped, asked for again on the next frame, loaded again, and so on. Traced at render distance 16 after a teleport to the PerfBench village: chunk (-41, 4) went submit → load → dropped dozens of times in 20 s. 7–9 such columns permanently held that many of the 39 in-flight generation slots, kept a worker reading the save, and meant status.streaming.generating never reached 0.

Fix

Ranges now owns the three predicates (requested, chunk_kept, unloaded), and they nest: every requested column is kept when it arrives, and no kept column is unloaded. For the vanilla generator, that keeps a thin ring of extra columns around finished chunks loaded (967 columns instead of 949 after the same teleport). Non-decorating generators are unchanged.

requested_columns_stay_loaded checks the nesting at render distances 2–32, with and without decoration, including an extra loaded area. It fails on the old rule ((0, -9) is asked for but dropped at radius 2). The existing spawn_neighbourhood_completes_at_every_distance now uses the same predicates.

Checked

  • The teleport trace: generating falls to 0 within 10 s and stays there (before: 7–9 forever).
  • cargo test -p horizon-client (597 passed), cargo clippy -p horizon-client --all-targets -D warnings, cargo fmt --check.

Found while benchmarking chunk loading (features item 6): perf_bench.py's load check (#264) waits for every streaming stage to be idle and timed out on this.

🤖 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/280 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/streaming-reload-loop` --- ### 📝 Commits (1) - [`0c685d9`](https://github.com/horizon-rust/horizon/commit/0c685d9db497aca30e86ae49de9d7b2da19c321c) Stop reloading saved columns every frame after the player moves ### 📊 Changes **1 file changed** (+67 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/streaming.rs` (+67 -17) </details> ### 📄 Description After the player moves far (a teleport, or flying fast), a few saved columns at the edge of the loaded area were loaded from disk, thrown away and loaded again **on every frame, forever**. ## What happened Three ranges in `Streaming::update` disagreed: | step | range | |---|---| | generation asks for a column | view distance + 3, or within 2 of a finished chunk | | a column that comes back finished is kept | view distance + 2, or within 1 of a finished chunk | | a column is unloaded | outside view distance + 3 and further than 1 from a finished chunk | A column that had been saved comes back from `generator.load` already finished. When it fell between the second and first rows, it was dropped, asked for again on the next frame, loaded again, and so on. Traced at render distance 16 after a teleport to the PerfBench village: chunk (-41, 4) went `submit → load → dropped` dozens of times in 20 s. 7–9 such columns permanently held that many of the 39 in-flight generation slots, kept a worker reading the save, and meant `status.streaming.generating` never reached 0. ## Fix `Ranges` now owns the three predicates (`requested`, `chunk_kept`, `unloaded`), and they nest: every requested column is kept when it arrives, and no kept column is unloaded. For the vanilla generator, that keeps a thin ring of extra columns around finished chunks loaded (967 columns instead of 949 after the same teleport). Non-decorating generators are unchanged. `requested_columns_stay_loaded` checks the nesting at render distances 2–32, with and without decoration, including an extra loaded area. It fails on the old rule (`(0, -9) is asked for but dropped` at radius 2). The existing `spawn_neighbourhood_completes_at_every_distance` now uses the same predicates. ## Checked - The teleport trace: `generating` falls to 0 within 10 s and stays there (before: 7–9 forever). - `cargo test -p horizon-client` (597 passed), `cargo clippy -p horizon-client --all-targets -D warnings`, `cargo fmt --check`. Found while benchmarking chunk loading (features item 6): `perf_bench.py`'s load check (#264) waits for every streaming stage to be idle and timed out on this. 🤖 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:56:17 +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#2454
No description provided.