[PR #7166] [MERGED] Telemetry: name the step behind each frame over 250 ms #7390

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7166
Author: @ludovic111
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: perf/slow-frame-spans


📝 Commits (2)

  • e78f71a Telemetry: what slow frames spent their time in
  • ad88c25 dedicated report test: spans carry their depth

📊 Changes

8 files changed (+528 additions, -32 deletions)

View changed files

📝 crates/horizon-client-render/src/spans.rs (+173 -12)
📝 crates/horizon-client-render/src/telemetry.rs (+52 -7)
📝 crates/horizon-client/src/game.rs (+18 -2)
📝 crates/horizon-client/src/game/dedicated/report.rs (+1 -0)
📝 crates/horizon-telemetry-server/src/store.rs (+106 -8)
📝 crates/horizon-telemetry-server/tests/server.rs (+52 -1)
📝 crates/horizon-telemetry/src/payload.rs (+122 -0)
📝 docs/telemetry.md (+4 -2)

📄 Description

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

A player's perf report says "276 frames over 250 ms" but not what froze. With this PR, the opt-in perf item also says which step took most of each slow frame.

What changes

  • Client (spans.rs, telemetry.rs, game.rs): when the player allowed performance telemetry, the window's main thread records its spans' wall time (plus their nesting depth). This is the only new cost. Without consent nothing is recorded; HORIZON_SPIKES works as before. In a frame of 250 ms or more, spans::culprit follows the nesting tree from the root and goes down while one child holds at least half of its parent. For example, renderer → renderer/submit → (no child holds half) stops at renderer/submit. The session counts these frames per step.
  • Payload (horizon-telemetry): Perf.slow_frames: [{span, frames, frame_max_ms, span_max_ms}]. There are at most 16 entries: 15 named, then everything else goes under "other". Names are capped at 64 bytes. The payload stays well under the 4 KiB item limit, and validate refuses anything longer. The field is omitted when empty, so older servers keep accepting new clients.
  • Ingest server (horizon-telemetry-server): a new slow_frames column. migrate adds it to existing databases. /v1/aggregate returns slow_frames per (version, span): frames, sessions, installs, and the worst frame and span times. Like every other aggregate, it hides a row until min_install_days distinct installs report it.
  • Docs: docs/telemetry.md describes the field and the aggregate.
  • Benchmark format: no change. horizon-bench reports have their own schema, and a benchmark run can turn on HORIZON_SPIKES for full spans.

Cost

Micro-benchmark of the same recording code (rustc -O, M4 Pro, 100 spans per frame): 4.9–5.0 µs per frame while recording, 0.11 µs when off. At 60 fps that is about 0.03% of a frame budget, and only for players who opted in.

Tested

  • End to end on Linux (playhorizon, llvmpipe, Xvfb): a scratch home with performance consent, a world for 150 s, then SIGTERM. The outbox perf item had seconds 141, frames 533, 250+ 276 and:
    [{"span":"renderer/submit","frames":145,"frame_max_ms":1081.5,"span_max_ms":1074.0},
     {"span":"renderer","frames":131,"frame_max_ms":1287.3,"span_max_ms":1279.4}]
    
    On a software renderer the GPU submit is expected to be the slow step.
  • Unit tests: horizon-telemetry (cap and other bucket), render spans:: (nesting kept, culprit chosen), telemetry:: (session counts slow frames per step), server store migration from a pre-slow_frames database, and server /v1/aggregate k-anonymity for slow_frames.
  • crates/horizon-telemetry-server (its own workspace): cargo fmt --check, cargo clippy -- -D warnings, cargo test (52 passed).

🤖 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/7166 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/slow-frame-spans` --- ### 📝 Commits (2) - [`e78f71a`](https://github.com/horizon-rust/horizon/commit/e78f71a47b815e317896aea84af97899d53dc2ed) Telemetry: what slow frames spent their time in - [`ad88c25`](https://github.com/horizon-rust/horizon/commit/ad88c2584dc078f394772c960851fe460e8ba6e7) dedicated report test: spans carry their depth ### 📊 Changes **8 files changed** (+528 additions, -32 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/spans.rs` (+173 -12) 📝 `crates/horizon-client-render/src/telemetry.rs` (+52 -7) 📝 `crates/horizon-client/src/game.rs` (+18 -2) 📝 `crates/horizon-client/src/game/dedicated/report.rs` (+1 -0) 📝 `crates/horizon-telemetry-server/src/store.rs` (+106 -8) 📝 `crates/horizon-telemetry-server/tests/server.rs` (+52 -1) 📝 `crates/horizon-telemetry/src/payload.rs` (+122 -0) 📝 `docs/telemetry.md` (+4 -2) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. A player's perf report says "276 frames over 250 ms" but not what froze. With this PR, the opt-in `perf` item also says which step took most of each slow frame. ## What changes - **Client (`spans.rs`, `telemetry.rs`, `game.rs`)**: when the player allowed `performance` telemetry, the window's main thread records its spans' wall time (plus their nesting depth). This is the only new cost. Without consent nothing is recorded; `HORIZON_SPIKES` works as before. In a frame of 250 ms or more, `spans::culprit` follows the nesting tree from the root and goes down while one child holds at least half of its parent. For example, `renderer` → `renderer/submit` → (no child holds half) stops at `renderer/submit`. The session counts these frames per step. - **Payload (`horizon-telemetry`)**: `Perf.slow_frames: [{span, frames, frame_max_ms, span_max_ms}]`. There are at most 16 entries: 15 named, then everything else goes under `"other"`. Names are capped at 64 bytes. The payload stays well under the 4 KiB item limit, and `validate` refuses anything longer. The field is omitted when empty, so older servers keep accepting new clients. - **Ingest server (`horizon-telemetry-server`)**: a new `slow_frames` column. `migrate` adds it to existing databases. `/v1/aggregate` returns `slow_frames` per (version, span): frames, sessions, installs, and the worst frame and span times. Like every other aggregate, it hides a row until `min_install_days` distinct installs report it. - **Docs**: `docs/telemetry.md` describes the field and the aggregate. - **Benchmark format**: no change. `horizon-bench` reports have their own schema, and a benchmark run can turn on `HORIZON_SPIKES` for full spans. ## Cost Micro-benchmark of the same recording code (rustc -O, M4 Pro, 100 spans per frame): **4.9–5.0 µs per frame** while recording, 0.11 µs when off. At 60 fps that is about 0.03% of a frame budget, and only for players who opted in. ## Tested - End to end on Linux (playhorizon, llvmpipe, Xvfb): a scratch home with `performance` consent, a world for 150 s, then SIGTERM. The outbox perf item had `seconds 141, frames 533, 250+ 276` and: ```json [{"span":"renderer/submit","frames":145,"frame_max_ms":1081.5,"span_max_ms":1074.0}, {"span":"renderer","frames":131,"frame_max_ms":1287.3,"span_max_ms":1279.4}] ``` On a software renderer the GPU submit is expected to be the slow step. - Unit tests: `horizon-telemetry` (cap and `other` bucket), render `spans::` (nesting kept, culprit chosen), `telemetry::` (session counts slow frames per step), server store migration from a pre-`slow_frames` database, and server `/v1/aggregate` k-anonymity for `slow_frames`. - `crates/horizon-telemetry-server` (its own workspace): `cargo fmt --check`, `cargo clippy -- -D warnings`, `cargo test` (52 passed). 🤖 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 06:38:49 +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#7390
No description provided.