[PR #6285] [MERGED] Far terrain: finishes loading in about a minute instead of seven on 4-thread machines #6767

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6285
Author: @some-du6e
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: perf/lod-settle-faster


📝 Commits (10+)

  • 807fd8b Merge main: the index crash fix after translucent sections (#5702)
  • 71c2161 Far terrain: hold back only while the near terrain loads, not while it remeshes
  • 99e71ad Far terrain: queue 32 sample jobs per thread once the near terrain is in
  • 064cd6c Status: how many far columns have their generated detail
  • e23cc14 Far decoration: a third of the threads, rounded up
  • 6833b98 Merge main
  • c95422c Far terrain: give way to the near terrain at once, and count its light views
  • 025794d Far terrain: test both holds' budgets and the dropped tiles' return
  • 617a56e Far terrain: dropped samples go back in line, and the held pace restarts
  • c26f5f2 Streaming: terrain_loading, not a method named like the loading-screen field

📊 Changes

6 files changed (+227 additions, -23 deletions)

View changed files

📝 crates/horizon-client-render/src/lod.rs (+197 -16)
📝 crates/horizon-client-render/src/streaming.rs (+18 -3)
📝 crates/horizon-client/src/game.rs (+1 -1)
📝 crates/horizon-client/src/game/control.rs (+6 -0)
📝 crates/horizon-client/src/vanillagen/lod.rs (+4 -2)
📝 docs/graphics.md (+1 -1)

📄 Description

On a 4-thread machine, far terrain took 7+ minutes to finish loading. In CI (render distance 12, LOD Distance 64, Full far detail, lavapipe) 95% of the far tiles weren't sampled after 8 minutes, and the far trees and structures took about 11. The far sampling thread was idle most of that time: it used 23 s of CPU in 8 minutes while the runner had spare cores.

Two things held it back:

  • Remeshes counted as loading. The far terrain held back (one sample every 500 ms, no far meshing) whenever Streaming::busy() was true. That counts every section being remeshed, so any block, light or fluid update near the player kept it held long after the near chunks were in. The new Streaming::terrain_loading() counts only chunks still being generated, decorated, finished or lit, and sections meshing for the first time. When the near terrain starts loading again, queued sample jobs past the held budget are dropped, so it gives way at once.
  • The frame rate capped sampling. Only 4 sample jobs could be in flight, and results are collected once a frame. At 2-3 fps that's about 1.5 tiles a frame, with the sampler idle for most of it. Once the near terrain is in, up to 32 jobs per sampling thread can now be queued. Queued tiles the view leaves are dropped at the replan.

Far decoration (generated trees and structures) also gets a third of the threads rounded up instead of rounded down: two on a 4-thread machine instead of one. They still run at idle priority. The status reports its progress as lod.detail_target_columns / lod.refined_target_columns.

Nothing changes what's sampled or meshed, so the far terrain looks the same.

Measured in CI

A side-by-side recording on the fork (tools/demo/lod_seam.py on demo/lod-settle-faster, not part of this PR: seed 1 above jagged peaks, a new world, 4-thread runner, lavapipe):

95% of far tiles sampled 95% of far detail (trees, structures)
before 445 s / not reached by 480 s (two runs) 641 s
after 75 s 427 s

The cost: while the far detail loads, the CPU-rendered frame rate drops about 20% (2.2 → 1.7 fps on lavapipe), because the second decoration thread shares the runner's cores. It recovers once the detail is in. On a GPU the frame barely uses the CPU, so I expect little or no drop there, but I haven't measured it.

Tests: queued_samples_follow_the_view_and_make_way_for_the_near_terrain (a move keeps the still-planned queued tiles in order, a teleport drops the old view's, and the queue gives way as soon as the near terrain loads again) and detail_progress_counts_the_columns_that_take_generated_detail. cargo fmt, clippy -D warnings and cargo test -p horizon-client-render --lib lod passed on the fork's Actions; nothing was built locally.

Note

Filed by Opus 5.5 using 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/6285 **Author:** [@some-du6e](https://github.com/some-du6e) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/lod-settle-faster` --- ### 📝 Commits (10+) - [`807fd8b`](https://github.com/horizon-rust/horizon/commit/807fd8b48ab1b5c6e8be041f582230ac675419b0) Merge main: the index crash fix after translucent sections (#5702) - [`71c2161`](https://github.com/horizon-rust/horizon/commit/71c2161c739d7d44db1004fe7f9943a2d735d143) Far terrain: hold back only while the near terrain loads, not while it remeshes - [`99e71ad`](https://github.com/horizon-rust/horizon/commit/99e71addf808ae095339121f7f2d58e60f9a37b2) Far terrain: queue 32 sample jobs per thread once the near terrain is in - [`064cd6c`](https://github.com/horizon-rust/horizon/commit/064cd6c99c0f0cea0d2cdf166b87377d3a6ca47e) Status: how many far columns have their generated detail - [`e23cc14`](https://github.com/horizon-rust/horizon/commit/e23cc142442f634a335daae047ef8d7ba8e5b29f) Far decoration: a third of the threads, rounded up - [`6833b98`](https://github.com/horizon-rust/horizon/commit/6833b9849400f659581fc1cedf8839d42799dbde) Merge main - [`c95422c`](https://github.com/horizon-rust/horizon/commit/c95422cbf18716a0404076e485918accc9241d8d) Far terrain: give way to the near terrain at once, and count its light views - [`025794d`](https://github.com/horizon-rust/horizon/commit/025794de8366c86bd23ec7ef9f49eb8fd072d002) Far terrain: test both holds' budgets and the dropped tiles' return - [`617a56e`](https://github.com/horizon-rust/horizon/commit/617a56e44ddf56888c6b1a3b1d34c42f5c6b75e8) Far terrain: dropped samples go back in line, and the held pace restarts - [`c26f5f2`](https://github.com/horizon-rust/horizon/commit/c26f5f2fc77a26ce32e746a7696f94057dae83cb) Streaming: terrain_loading, not a method named like the loading-screen field ### 📊 Changes **6 files changed** (+227 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/lod.rs` (+197 -16) 📝 `crates/horizon-client-render/src/streaming.rs` (+18 -3) 📝 `crates/horizon-client/src/game.rs` (+1 -1) 📝 `crates/horizon-client/src/game/control.rs` (+6 -0) 📝 `crates/horizon-client/src/vanillagen/lod.rs` (+4 -2) 📝 `docs/graphics.md` (+1 -1) </details> ### 📄 Description On a 4-thread machine, far terrain took 7+ minutes to finish loading. In CI (render distance 12, LOD Distance 64, Full far detail, lavapipe) 95% of the far tiles weren't sampled after 8 minutes, and the far trees and structures took about 11. The far sampling thread was idle most of that time: it used 23 s of CPU in 8 minutes while the runner had spare cores. Two things held it back: - **Remeshes counted as loading.** The far terrain held back (one sample every 500 ms, no far meshing) whenever `Streaming::busy()` was true. That counts every section being remeshed, so any block, light or fluid update near the player kept it held long after the near chunks were in. The new `Streaming::terrain_loading()` counts only chunks still being generated, decorated, finished or lit, and sections meshing for the first time. When the near terrain starts loading again, queued sample jobs past the held budget are dropped, so it gives way at once. - **The frame rate capped sampling.** Only 4 sample jobs could be in flight, and results are collected once a frame. At 2-3 fps that's about 1.5 tiles a frame, with the sampler idle for most of it. Once the near terrain is in, up to 32 jobs per sampling thread can now be queued. Queued tiles the view leaves are dropped at the replan. Far decoration (generated trees and structures) also gets a third of the threads rounded up instead of rounded down: two on a 4-thread machine instead of one. They still run at idle priority. The status reports its progress as `lod.detail_target_columns` / `lod.refined_target_columns`. Nothing changes what's sampled or meshed, so the far terrain looks the same. ### Measured in CI A side-by-side recording on the fork ([`tools/demo/lod_seam.py` on `demo/lod-settle-faster`](https://github.com/some-du6e/horizon/blob/demo/lod-settle-faster/tools/demo/lod_seam.py), not part of this PR: seed 1 above jagged peaks, a new world, 4-thread runner, lavapipe): | | 95% of far tiles sampled | 95% of far detail (trees, structures) | |---|---|---| | before | 445 s / not reached by 480 s (two runs) | 641 s | | after | 75 s | 427 s | The cost: while the far detail loads, the CPU-rendered frame rate drops about 20% (2.2 → 1.7 fps on lavapipe), because the second decoration thread shares the runner's cores. It recovers once the detail is in. On a GPU the frame barely uses the CPU, so I expect little or no drop there, but I haven't measured it. Tests: `queued_samples_follow_the_view_and_make_way_for_the_near_terrain` (a move keeps the still-planned queued tiles in order, a teleport drops the old view's, and the queue gives way as soon as the near terrain loads again) and `detail_progress_counts_the_columns_that_take_generated_detail`. `cargo fmt`, `clippy -D warnings` and `cargo test -p horizon-client-render --lib lod` passed on the fork's Actions; nothing was built locally. > [!NOTE] > Filed by Opus 5.5 using 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:26:20 +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#6767
No description provided.