[GH-ISSUE #678] [performance] Camera movement feels choppy at 32 chunks despite 500+ FPS (frame pacing) #207

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

Originally created by @ludovic111 on GitHub (Oct 17, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/678

Reported by rickdickem on Discord (#horizon-chat, 2026-10-17 08:21 UTC).

I don't get frame drops and my FPS in normal gameplay never drops below 500fps but the camera movement feels pretty choppy at times

  • Render distance 32: happens. Render distance 16: doesn't happen.
  • Fullscreen, the immediate present mode.
  • Otherwise performance is good. They measured about 14% more FPS than Java with Sodium.

Likely frame-time variance rather than low average FPS: uneven frame intervals, or occasional long frames from chunk mesh uploads or visibility work at large render distances, which the FPS counter hides. What to measure: frame-time p99/p99.9 and per-frame mesh upload bytes at RD16 vs RD32 while turning the camera, and whether the camera's interpolation uses the actual frame delta.

Related: #495 (tick spikes on the render thread), #600 (crash at 32 chunks), and #676 (Online5277: releasing unused terrain GPU buffers).

🤖 Generated with Claude Code

Originally created by @ludovic111 on GitHub (Oct 17, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/678 Reported by **rickdickem** on Discord (#horizon-chat, 2026-10-17 08:21 UTC). > I don't get frame drops and my FPS in normal gameplay never drops below 500fps but the camera movement feels pretty choppy at times - Render distance 32: happens. Render distance 16: doesn't happen. - Fullscreen, the immediate present mode. - Otherwise performance is good. They measured about 14% more FPS than Java with Sodium. Likely frame-time variance rather than low average FPS: uneven frame intervals, or occasional long frames from chunk mesh uploads or visibility work at large render distances, which the FPS counter hides. What to measure: frame-time p99/p99.9 and per-frame mesh upload bytes at RD16 vs RD32 while turning the camera, and whether the camera's interpolation uses the actual frame delta. Related: #495 (tick spikes on the render thread), #600 (crash at 32 chunks), and #676 (Online5277: releasing unused terrain GPU buffers). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
bsakaguchi 2026-11-02 15:37:17 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@ludovic111 commented on GitHub (Oct 21, 2026):

🤖 Agent: measured, no fix in this batch yet. What the numbers show:

Desktop (Ryzen, RTX 4080, Linux/Vulkan, other jobs running), seed 1234, flying the same 192-block path back and forth, 12 s per run, raw frame times, main at 55133617:

p50 p99 p99.9
RD 16 0.73–0.77 ms 6.2–6.6 ms 10–11 ms
RD 32 2.2–3.0 ms 10–14.5 ms 23–31 ms
RD 32, --server-thread 1.4–2.1 ms 5.6–9.3 ms 23–25 ms

The average FPS stays high (275–380 at RD 32) but about 1 frame in 100 takes 10–30 ms, which is what feels choppy. With HORIZON_SPIKES=6 the slow frames at RD 32 are almost all frames that run a game tick: the integrated server ticks on the render thread, and its tick there takes 5–20 ms, most of it in tick_blocks and inside it the scheduled block and fluid ticks (7–13 ms) of the chunks that are being loaded, with a rare tick_mobs spike of 40–70 ms. Mesh uploads and visibility are not the long part.

So the fix is the server off the render thread (--server-thread today; making it the default, #731, is on hold until the server sends clients every entity type) plus cheaper scheduled ticks in freshly loaded chunks (probably the same extra block updates as #996). Until then --server-thread roughly halves p99 at 32 chunks. Leaving this open for those.

<!-- gh-comment-id:6316054081 --> @ludovic111 commented on GitHub (Oct 21, 2026): 🤖 Agent: measured, no fix in this batch yet. What the numbers show: Desktop (Ryzen, RTX 4080, Linux/Vulkan, other jobs running), seed 1234, flying the same 192-block path back and forth, 12 s per run, raw frame times, `main` at 55133617: | | p50 | p99 | p99.9 | |---|---|---|---| | RD 16 | 0.73–0.77 ms | 6.2–6.6 ms | 10–11 ms | | RD 32 | 2.2–3.0 ms | 10–14.5 ms | 23–31 ms | | RD 32, `--server-thread` | 1.4–2.1 ms | 5.6–9.3 ms | 23–25 ms | The average FPS stays high (275–380 at RD 32) but about 1 frame in 100 takes 10–30 ms, which is what feels choppy. With `HORIZON_SPIKES=6` the slow frames at RD 32 are almost all frames that run a game tick: the integrated server ticks on the render thread, and its tick there takes 5–20 ms, most of it in `tick_blocks` and inside it the scheduled block and fluid ticks (7–13 ms) of the chunks that are being loaded, with a rare `tick_mobs` spike of 40–70 ms. Mesh uploads and visibility are not the long part. So the fix is the server off the render thread (`--server-thread` today; making it the default, #731, is on hold until the server sends clients every entity type) plus cheaper scheduled ticks in freshly loaded chunks (probably the same extra block updates as #996). Until then `--server-thread` roughly halves p99 at 32 chunks. Leaving this open for those.
Author
Owner

@ludovic111 commented on GitHub (Oct 21, 2026):

🤖 Agent: tick cost in freshly loaded chunks, measured for #996 (fix in #1110). Dedicated server, seed 12345, view/simulation distance 10, one horizon-bots bot for 150 s, mspt queried every 10 s on the Mac mini (M4 Pro), the same way before and after.

Run Horizon main With #1110 Vanilla 26.3
fresh world, mixed bot 2.16 ms avg (worst window p99 4.6) 2.09 ms (p99 7.2 in one window, 2.8–4.7 in the others) 9.57 ms (p99 144.5)
fresh world, idle bot 1.94 ms (p99 3.7) 1.97 ms (p99 4.0) 7.06 ms (p99 74.9)
walk into new chunks of a generated world 1.72–1.80 ms (p99 4.5–4.9) 1.82 ms (p99 4.2) 13.85 ms (p99 155.5)

On the server thread, fresh chunks cost about 2 ms a tick with or without the fix, a fifth of vanilla's. The fix doesn't change the frame spikes reported here: per the perf-frame-cost notes, those come from the integrated server's tick running on the render thread.

<!-- gh-comment-id:6325944486 --> @ludovic111 commented on GitHub (Oct 21, 2026): 🤖 Agent: tick cost in freshly loaded chunks, measured for #996 (fix in #1110). Dedicated server, seed 12345, view/simulation distance 10, one horizon-bots bot for 150 s, `mspt` queried every 10 s on the Mac mini (M4 Pro), the same way before and after. | Run | Horizon main | With #1110 | Vanilla 26.3 | |---|---:|---:|---:| | fresh world, mixed bot | 2.16 ms avg (worst window p99 4.6) | 2.09 ms (p99 7.2 in one window, 2.8–4.7 in the others) | 9.57 ms (p99 144.5) | | fresh world, idle bot | 1.94 ms (p99 3.7) | 1.97 ms (p99 4.0) | 7.06 ms (p99 74.9) | | walk into new chunks of a generated world | 1.72–1.80 ms (p99 4.5–4.9) | 1.82 ms (p99 4.2) | 13.85 ms (p99 155.5) | On the server thread, fresh chunks cost about 2 ms a tick with or without the fix, a fifth of vanilla's. The fix doesn't change the frame spikes reported here: per the perf-frame-cost notes, those come from the integrated server's tick running on the render thread.
Author
Owner

@ludovic111 commented on GitHub (Oct 22, 2026):

🤖 Agent: three PRs for this, measured on the Mac mini (M4 Pro, Metal). Setup: seed 1234, RD 32, --server-thread, raw frame times, interleaved A/B runs.

Cause 1: the render thread lost its core.

  • The render thread ran at the same priority as 24 world-generation and meshing workers (two pools of N−2 with the server thread) and 13 chunk encoders.
  • Most frames over 12 ms did less than 1 ms of work. They gave the core up in queue.submit and waited 10–200 ms to get it back.
  • #1179 puts the render thread ahead of the workers, as the server thread already was: user-interactive QoS on macOS, above-normal priority on Windows.
  • #1178 makes HORIZON_SPIKES show this: each span's CPU time beside its wall time, e.g. submit 33.3/0.1.

Cause 2: chunk batches decoded in one frame.

  • Each chunk border crossed at RD 32 brings 25–60 columns, about 0.12 ms each to decode, all in one frame.
  • #1181 gives chunk packets 1 ms a frame. Later packets wait for the next frame, in order, never more than a tick.
Back and forth over loaded terrain p50 p99 p99.9 max
main 2.2–2.4 ms 14.4–17.5 ms 38.5–39.2 ms 85–115 ms
+ #1179 1.6–1.7 ms 3.3 ms 7.7–8.6 ms 12–17 ms
+ #1179 + #1181 1.5–1.6 ms 3.1–3.2 ms 4.0–4.1 ms 11–17 ms

Fresh terrain (30 s flight while the world loads): p99.9 went from 89–207 ms to 3.4–5.6 ms with #1179. The full tables are in the PRs.

Left open: on macOS, p99.9 is now close to p99. Linux is not done:

  • An unprivileged thread can't raise itself there, so #1179 does nothing on Linux.
  • The matching fix would put the client's workers behind the render thread (what the dedicated server already does). It needs a measurement on the desktop.
  • That and the remaining items are in FEATURES.md LATER (4r).
<!-- gh-comment-id:6335893126 --> @ludovic111 commented on GitHub (Oct 22, 2026): 🤖 Agent: three PRs for this, measured on the Mac mini (M4 Pro, Metal). Setup: seed 1234, RD 32, `--server-thread`, raw frame times, interleaved A/B runs. **Cause 1: the render thread lost its core.** - The render thread ran at the same priority as 24 world-generation and meshing workers (two pools of N−2 with the server thread) and 13 chunk encoders. - Most frames over 12 ms did less than 1 ms of work. They gave the core up in `queue.submit` and waited 10–200 ms to get it back. - **#1179** puts the render thread ahead of the workers, as the server thread already was: user-interactive QoS on macOS, above-normal priority on Windows. - **#1178** makes `HORIZON_SPIKES` show this: each span's CPU time beside its wall time, e.g. `submit 33.3/0.1`. **Cause 2: chunk batches decoded in one frame.** - Each chunk border crossed at RD 32 brings 25–60 columns, about 0.12 ms each to decode, all in one frame. - **#1181** gives chunk packets 1 ms a frame. Later packets wait for the next frame, in order, never more than a tick. | Back and forth over loaded terrain | p50 | p99 | p99.9 | max | |---|---|---|---|---| | `main` | 2.2–2.4 ms | 14.4–17.5 ms | 38.5–39.2 ms | 85–115 ms | | + #1179 | 1.6–1.7 ms | 3.3 ms | 7.7–8.6 ms | 12–17 ms | | + #1179 + #1181 | 1.5–1.6 ms | 3.1–3.2 ms | 4.0–4.1 ms | 11–17 ms | Fresh terrain (30 s flight while the world loads): p99.9 went from 89–207 ms to 3.4–5.6 ms with #1179. The full tables are in the PRs. **Left open:** on macOS, p99.9 is now close to p99. Linux is not done: - An unprivileged thread can't raise itself there, so #1179 does nothing on Linux. - The matching fix would put the client's workers behind the render thread (what the dedicated server already does). It needs a measurement on the desktop. - That and the remaining items are in FEATURES.md LATER (4r).
Author
Owner

@ludovic111 commented on GitHub (Oct 22, 2026):

🤖 Agent: Linux half in #1192 (stacked on #1181 and #1179).

  • What it does: the client's world-generation and meshing workers and its LAN writers now run 10 nice levels below the render and server threads, as the dedicated server's helpers already did.
  • Setup: desktop, Vulkan, RD 32, --server-thread, a fresh world each run, interleaved A/B runs.
  • Moderate load (16–24): p99 6.9 → 4.1 ms, p99.9 22.2 → 9.8 ms, max 118 → 46 ms (pooled, 5 runs each).
  • Heavy load (34–80): p99.9 171 → 28 ms.
  • Chunk loading: not slower.

Still open: the shared desktop never went below load 16, so I couldn't measure an idle Linux machine. About half of the remaining Linux frames over 8 ms are other programs preempting the game. The other half are mesh uploads and an occasional overdue chunk-packet flush.

This is FEATURES 4r. Close #678 once an idle-machine run shows p99.9 within about 2× p99. The Mac is already there: 4.0 vs 3.2 ms.

<!-- gh-comment-id:6338090141 --> @ludovic111 commented on GitHub (Oct 22, 2026): 🤖 Agent: Linux half in #1192 (stacked on #1181 and #1179). - **What it does:** the client's world-generation and meshing workers and its LAN writers now run 10 nice levels below the render and server threads, as the dedicated server's helpers already did. - **Setup:** desktop, Vulkan, RD 32, `--server-thread`, a fresh world each run, interleaved A/B runs. - **Moderate load (16–24):** p99 6.9 → 4.1 ms, p99.9 22.2 → 9.8 ms, max 118 → 46 ms (pooled, 5 runs each). - **Heavy load (34–80):** p99.9 171 → 28 ms. - **Chunk loading:** not slower. **Still open:** the shared desktop never went below load 16, so I couldn't measure an idle Linux machine. About half of the remaining Linux frames over 8 ms are other programs preempting the game. The other half are mesh uploads and an occasional overdue chunk-packet flush. This is FEATURES 4r. Close #678 once an idle-machine run shows p99.9 within about 2× p99. The Mac is already there: 4.0 vs 3.2 ms.
Author
Owner

@rdbtCVS commented on GitHub (Oct 25, 2026):

This is fixed now with server-thread. Close now.

<!-- gh-comment-id:6391911952 --> @rdbtCVS commented on GitHub (Oct 25, 2026): This is fixed now with server-thread. Close now.
Author
Owner

@rdbtCVS commented on GitHub (Oct 26, 2026):

🤖 Agent: rdbtCVS’s AI agent (OpenAI Codex), triage follow-up. The latest confirmation here explicitly says this is fixed with server-thread singleplayer and asks for closure. Recommend closing as fixed; a remaining reproducible frame-pacing problem on a current build should retain its own settings and frame-time evidence.

<!-- gh-comment-id:6418375467 --> @rdbtCVS commented on GitHub (Oct 26, 2026): 🤖 Agent: rdbtCVS’s AI agent (OpenAI Codex), triage follow-up. The latest confirmation here explicitly says this is fixed with server-thread singleplayer and asks for closure. Recommend closing as fixed; a remaining reproducible frame-pacing problem on a current build should retain its own settings and frame-time evidence.
Author
Owner

@kacpherek commented on GitHub (Oct 30, 2026):

This looks fixed on main: Frame pacing fixed with server-thread single player (#1192); a reporter asked to close. Closing; if it still happens on the latest build, please reopen with your version and logs/latest.log.

<!-- gh-comment-id:6527755394 --> @kacpherek commented on GitHub (Oct 30, 2026): This looks fixed on main: Frame pacing fixed with server-thread single player (#1192); a reporter asked to close. Closing; if it still happens on the latest build, please reopen with your version and `logs/latest.log`.
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#207
No description provided.