[PR #1178] [MERGED] Slow-frame lines show each span's CPU time (HORIZON_SPIKES) #3391

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

📋 Pull Request Information

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

Base: main ← Head: perf/span-cpu-time


📝 Commits (1)

  • c2b7f3a Slow-frame and slow-tick lines show the CPU time of each span

📊 Changes

4 files changed (+103 additions, -27 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+13 -8)
📝 crates/horizon-client/src/game/levels.rs (+1 -6)
📝 crates/horizon-client/src/spans.rs (+88 -12)
📝 docs/graphics.md (+1 -1)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Part of #678 (no Fixes: see the last PR of the set).

What

HORIZON_SPIKES=MS now tells a frame that worked apart from a frame that waited:

  • Every span keeps the thread's CPU time beside its wall time. A span that mostly waited (for the GPU, a lock or a core) prints both: submit 30.2/0.1.
  • The slow-frame line gives the render thread's CPU time in the frame: slow frame 33.6 ms, cpu 0.5 ms (0 ticks): renderer 33.6/0.4, submit 33.3/0.1.
  • Slow server ticks use the same format.

Spans cost one more clock read when HORIZON_SPIKES is set, and nothing more when it isn't. The per-frame thread clock is read only when it is set.

Why

This is how #678's long frames were found. At render distance 32 with the server thread, most frames over 12 ms looked like this:

slow frame 26.5 ms, cpu 0.4 ms (0 ticks): renderer 26.5/0.3, submit 26.3/0.1
slow frame 42.7 ms, cpu 0.4 ms (0 ticks): renderer 42.7/0.3, submit 42.5/0.2
slow frame 24.4 ms, cpu 0.7 ms (0 ticks): renderer 24.3/0.6, encode 24.1/0.5

The render thread did less than a millisecond of work in those frames: it gave its core up in queue.submit and waited 10 to 200 ms to get one back. The fix is #1179 (render thread ahead of the workers).

How tested (Mac mini M4 Pro)

  • cargo fmt --all --check: ok
  • set -o pipefail; cargo clippy --workspace --all-targets -- -D warnings: ok
  • cargo test -p horizon-client: 985 + 91 + 15 + 2 + 2 + 2 + 1 passed, 0 failed. New test spans_sum_by_name_and_show_waits.
  • tools/parity.py --changed origin/main, on one integration commit with the two other #678 PRs: 102 passed, 0 failed (no failure, so no main run was needed to compare).
  • Nothing changes on screen.

Label: skip-release (a developer tool).

🤖 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/1178 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/span-cpu-time` --- ### 📝 Commits (1) - [`c2b7f3a`](https://github.com/horizon-rust/horizon/commit/c2b7f3a4ea2dc5fdb86f4aa6469eabc4b2a26e22) Slow-frame and slow-tick lines show the CPU time of each span ### 📊 Changes **4 files changed** (+103 additions, -27 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+13 -8) 📝 `crates/horizon-client/src/game/levels.rs` (+1 -6) 📝 `crates/horizon-client/src/spans.rs` (+88 -12) 📝 `docs/graphics.md` (+1 -1) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Part of #678 (no `Fixes`: see the last PR of the set). ## What `HORIZON_SPIKES=MS` now tells a frame that worked apart from a frame that waited: - Every span keeps the thread's CPU time beside its wall time. A span that mostly waited (for the GPU, a lock or a core) prints both: `submit 30.2/0.1`. - The slow-frame line gives the render thread's CPU time in the frame: `slow frame 33.6 ms, cpu 0.5 ms (0 ticks): renderer 33.6/0.4, submit 33.3/0.1`. - Slow server ticks use the same format. Spans cost one more clock read when `HORIZON_SPIKES` is set, and nothing more when it isn't. The per-frame thread clock is read only when it is set. ## Why This is how #678's long frames were found. At render distance 32 with the server thread, most frames over 12 ms looked like this: ``` slow frame 26.5 ms, cpu 0.4 ms (0 ticks): renderer 26.5/0.3, submit 26.3/0.1 slow frame 42.7 ms, cpu 0.4 ms (0 ticks): renderer 42.7/0.3, submit 42.5/0.2 slow frame 24.4 ms, cpu 0.7 ms (0 ticks): renderer 24.3/0.6, encode 24.1/0.5 ``` The render thread did less than a millisecond of work in those frames: it gave its core up in `queue.submit` and waited 10 to 200 ms to get one back. The fix is #1179 (render thread ahead of the workers). ## How tested (Mac mini M4 Pro) - `cargo fmt --all --check`: ok - `set -o pipefail; cargo clippy --workspace --all-targets -- -D warnings`: ok - `cargo test -p horizon-client`: 985 + 91 + 15 + 2 + 2 + 2 + 1 passed, 0 failed. New test `spans_sum_by_name_and_show_waits`. - `tools/parity.py --changed origin/main`, on one integration commit with the two other #678 PRs: **102 passed, 0 failed** (no failure, so no main run was needed to compare). - Nothing changes on screen. Label: `skip-release` (a developer tool). 🤖 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:12 +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#3391
No description provided.