[PR #3698] [MERGED] chunk loading: a worker frees the meshes the frame has uploaded #5155

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3698
Author: @iLostName
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @levzzz5154

Base: main ← Head: smooth-chunk-arrival


📝 Commits (1)

  • 75600ca chunk loading: a worker frees the meshes the frame has uploaded

📊 Changes

3 files changed (+45 additions, -10 deletions)

View changed files

📝 crates/horizon-client-render/src/streaming.rs (+24 -1)
📝 crates/horizon-client/src/game.rs (+17 -8)
📝 crates/horizon-client/tests/streaming_meshes.rs (+4 -1)

📄 Description

What and why

While chunks stream in, the render thread uploaded each finished section mesh and then freed it itself. At a chunk border hundreds of meshes arrive at once, and those frees waited on the allocator behind the busy meshing and generation workers: 7–22 ms of wall time per border frame against 1–3 ms of CPU while flying at render distance 32 (596 of 1000 ms of update_world over the slow frames, measured with temporary spans). The renderer now hands uploaded and stale meshes to Streaming::free, whose workers free them ahead of other jobs, as vanilla's CompileTask.doTask closes its mesh data on the worker. Uploads, their order and their frame are unchanged, so nothing drawn changes, and spawn loading takes the same time. Refs #1890.

Measurements

Fast profile, RTX 3070, 16 threads, 1280×720 window, vsync off, uncapped; 4 interleaved runs per build, a fresh world with seed 1234 each time. "Open": world frames from the second one until the spawn area is fully meshed (perf_bench's wait_loaded). "Fly": 600 blocks in 20 s into new terrain, pitch 10. Frame times in ms, base → this PR.

scenario p50 p95 p99 max > 33 ms > 50 ms time to loaded
RD12 open 0.9 → 0.8 1.9 → 1.9 2.9 → 2.9 39 → 39 4 → 4 0 → 0 6.45 → 6.95 s
RD20 open 1.5 → 1.5 3.1 → 2.7 4.3 → 3.8 43 → 40 4 → 4 0 → 0 10.78 → 9.78 s
RD32 open 1.9 → 2.0 3.5 → 3.6 4.6 → 4.8 40 → 61 4 → 4 0 → 1 16.54 → 16.93 s
RD12 fly 0.5 → 0.6 1.3 → 1.2 2.2 → 1.9 41 → 34 2 → 1 0 → 0 –
RD20 fly 1.0 → 1.0 2.3 → 2.3 3.4 → 3.3 26 → 11 0 → 0 0 → 0 –
RD32 fly 2.2 → 2.1 4.8 → 5.3 10.9 → 9.9 61 → 36 16 → 2 1 → 0 –
RD12 + LOD 256 fly (2 runs) – – – 54/18 → 15/15 2 → 0 1 → 0 –

At RD32 the frames over 20 ms while flying went from 124 to 9. The frames over 33 ms left when opening a world are the first frames after the world appears, in both builds: they wait on the GPU/present with ~2 ms of CPU, not on chunk work. Times to loaded differ within run-to-run noise.

Self-check

pr_ready (tools/pr_ready.py --quick on PC-Lost, against origin/main at 64990cd32, 5 min 48 s)

Check Result
Scope ✅ 3 files, +45 −10
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 408 run, FAILED (failures=1, skipped=12) (1 min 4 s)
rustfmt ✅ (10 s)
clippy ✅ (1 min 26 s)
tests: horizon-client, horizon-client-render ✅ 1294 passed (2 min 53 s)
doc tests ✅ 0 passed (12 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 ➖ not run (--quick): 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)

The one failure under Python tests is test_port_publish.PublishTests.test_body_has_names_and_signatures_only, a ~/ against ~\ path check that fails on Windows on main too. streaming_meshes.rs also ran against prepared resources (2 passed). Parity is left to CI.


🔄 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/3698 **Author:** [@iLostName](https://github.com/iLostName) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `smooth-chunk-arrival` --- ### 📝 Commits (1) - [`75600ca`](https://github.com/horizon-rust/horizon/commit/75600ca0467a8121b838f047fe106459c4b61b5e) chunk loading: a worker frees the meshes the frame has uploaded ### 📊 Changes **3 files changed** (+45 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/streaming.rs` (+24 -1) 📝 `crates/horizon-client/src/game.rs` (+17 -8) 📝 `crates/horizon-client/tests/streaming_meshes.rs` (+4 -1) </details> ### 📄 Description ## What and why While chunks stream in, the render thread uploaded each finished section mesh and then freed it itself. At a chunk border hundreds of meshes arrive at once, and those frees waited on the allocator behind the busy meshing and generation workers: 7–22 ms of wall time per border frame against 1–3 ms of CPU while flying at render distance 32 (596 of 1000 ms of `update_world` over the slow frames, measured with temporary spans). The renderer now hands uploaded and stale meshes to `Streaming::free`, whose workers free them ahead of other jobs, as vanilla's `CompileTask.doTask` closes its mesh data on the worker. Uploads, their order and their frame are unchanged, so nothing drawn changes, and spawn loading takes the same time. Refs #1890. ## Measurements Fast profile, RTX 3070, 16 threads, 1280×720 window, vsync off, uncapped; 4 interleaved runs per build, a fresh world with seed 1234 each time. "Open": world frames from the second one until the spawn area is fully meshed (`perf_bench`'s `wait_loaded`). "Fly": 600 blocks in 20 s into new terrain, pitch 10. Frame times in ms, base → this PR. | scenario | p50 | p95 | p99 | max | > 33 ms | > 50 ms | time to loaded | |---|---|---|---|---|---|---|---| | RD12 open | 0.9 → 0.8 | 1.9 → 1.9 | 2.9 → 2.9 | 39 → 39 | 4 → 4 | 0 → 0 | 6.45 → 6.95 s | | RD20 open | 1.5 → 1.5 | 3.1 → 2.7 | 4.3 → 3.8 | 43 → 40 | 4 → 4 | 0 → 0 | 10.78 → 9.78 s | | RD32 open | 1.9 → 2.0 | 3.5 → 3.6 | 4.6 → 4.8 | 40 → 61 | 4 → 4 | 0 → 1 | 16.54 → 16.93 s | | RD12 fly | 0.5 → 0.6 | 1.3 → 1.2 | 2.2 → 1.9 | 41 → 34 | 2 → 1 | 0 → 0 | – | | RD20 fly | 1.0 → 1.0 | 2.3 → 2.3 | 3.4 → 3.3 | 26 → 11 | 0 → 0 | 0 → 0 | – | | RD32 fly | 2.2 → 2.1 | 4.8 → 5.3 | 10.9 → 9.9 | 61 → 36 | 16 → 2 | 1 → 0 | – | | RD12 + LOD 256 fly (2 runs) | – | – | – | 54/18 → 15/15 | 2 → 0 | 1 → 0 | – | At RD32 the frames over 20 ms while flying went from 124 to 9. The frames over 33 ms left when opening a world are the first frames after the world appears, in both builds: they wait on the GPU/present with ~2 ms of CPU, not on chunk work. Times to loaded differ within run-to-run noise. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on PC-Lost, against origin/main at 64990cd32, 5 min 48 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +45 −10 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 408 run, FAILED (failures=1, skipped=12) (1 min 4 s) | | rustfmt | ✅ (10 s) | | clippy | ✅ (1 min 26 s) | | tests: horizon-client, horizon-client-render | ✅ 1294 passed (2 min 53 s) | | doc tests | ✅ 0 passed (12 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 | ➖ not run (--quick): 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) | The one failure under Python tests is `test_port_publish.PublishTests.test_body_has_names_and_signatures_only`, a `~/` against `~\` path check that fails on Windows on main too. `streaming_meshes.rs` also ran against prepared resources (2 passed). Parity is left to CI. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:10:38 +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#5155
No description provided.