[PR #6701] [MERGED] Frame pacing benchmark: tools/pacing_bench.py, horizon-ctl stats raw, spans::laps #7043

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

📋 Pull Request Information

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

Base: main ← Head: tools/pacing-bench


📝 Commits (3)

  • d5273ce Frame pacing benchmark: tools/pacing_bench.py, stats raw, spans::laps
  • a3d814e pacing_bench: the ocean flight scenario
  • d1ee2d8 pacing_bench: import its helpers as the other tools do (no sys.path change)

📊 Changes

9 files changed (+373 additions, -5 deletions)

View changed files

📝 crates/horizon-client-render/src/gfx.rs (+15 -0)
📝 crates/horizon-client-render/src/spans.rs (+43 -0)
📝 crates/horizon-client/src/bin/horizon-ctl/commands.rs (+1 -1)
📝 crates/horizon-client/src/game.rs (+17 -0)
📝 crates/horizon-client/src/game/control.rs (+8 -3)
📝 docs/benchmark.md (+18 -0)
📝 docs/horizon-ctl-commands.md (+1 -1)
➕ tests/test_pacing_bench.py (+28 -0)
➕ tools/pacing_bench.py (+242 -0)

📄 Description

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

What and why

tools/perf_bench.py measures throughput on short flights. Smoothness needs a different view: every frame of the sessions where players see hitches, and what the slow frames were doing. This PR adds that view, plus what the game needs to report it.

  • tools/pacing_bench.py: one fresh game per render distance (seed 1234, creative), driven over horizon-ctl, through these scenarios:

    • fly16: perf_bench's village flight;
    • ocean: perf_bench's ocean flight, Horizon's worst lows on Windows at RD 32;
    • fly64: 1,920 blocks of new terrain at 64 b/s;
    • teleport: 8 teleports of 1,500–3,000 blocks;
    • nether: overworld → Nether → overworld, twice;
    • inventory: the inventory and the pause menu, 20 times each.

    For each scenario it reports p50, p99, p99.9, max, 1% and 0.1% lows, frames over 33 ms and frames over twice the median, for the frame time and for the frame's CPU time. It also keeps the 12 slowest HORIZON_SPIKES lines of that scenario.

    Options: --size gives a small window, so a software renderer (lavapipe) doesn't hide the CPU side; --env; --run N keeps repeats apart. --compare A B prints the A/B tables (median of runs).

  • horizon-ctl stats raw and stats reset: stats raw returns every frame time since the last reset (frame_ms, cpu_ms, gpu_ms), and reset starts a new window. The scenarios record exactly their own frames. Help, MCP schema and docs/horizon-ctl-commands.md are updated.

  • spans::laps(): consecutive steps of one function timed as spans with one Instant each, free when HORIZON_SPIKES is off. entity_geometry (eg_*) and draw_frame (r_*) use it, so a slow frame says which step was slow. This is how the 41 ms first-leash-knot bake (#6656) and the 14 ms buffer frees (#6687) were found.

  • docs/benchmark.md: a "Frame pacing" section.

Players see no change: the laps cost nothing unless HORIZON_SPIKES is set, and stats without raw answers as before.

Measured

Tooling. Its first runs found #6656 and #6687, and it measures #6698.

Checks

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at 4bc8e359c, 8 min 34 s)

Check Result
Scope ✅ 9 files, +373 −5
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 600 passed (4 min 12 s)
rustfmt ✅ (9 s)
clippy ✅ (51 s)
tests: horizon-client, horizon-client-lib, horizon-client-render ✅ 2917 passed (3 min 4 s)
doc tests ✅ 0 passed (9 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 ➖ 132 affected, to run in CI (--quick): ambient_sound, armor_stand_frost, arrow, arrow_wind_charge, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, block_tint and 120 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

tests/test_pacing_bench.py checks the statistics against hand-computed values: percentiles, the lows as the mean of the slowest 1% and 0.1%, and the hitch counts. spans::tests::laps_time_consecutive_steps checks that laps split one function's time into its steps.

🤖 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/6701 **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:** `tools/pacing-bench` --- ### 📝 Commits (3) - [`d5273ce`](https://github.com/horizon-rust/horizon/commit/d5273ce67f90baa63188e93b39f633c3b1ae4dcd) Frame pacing benchmark: tools/pacing_bench.py, `stats raw`, spans::laps - [`a3d814e`](https://github.com/horizon-rust/horizon/commit/a3d814ec3f42dbd367ece30174f511acff98e201) pacing_bench: the ocean flight scenario - [`d1ee2d8`](https://github.com/horizon-rust/horizon/commit/d1ee2d879ccaa88415ee3f13beff94dfa202f903) pacing_bench: import its helpers as the other tools do (no sys.path change) ### 📊 Changes **9 files changed** (+373 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/gfx.rs` (+15 -0) 📝 `crates/horizon-client-render/src/spans.rs` (+43 -0) 📝 `crates/horizon-client/src/bin/horizon-ctl/commands.rs` (+1 -1) 📝 `crates/horizon-client/src/game.rs` (+17 -0) 📝 `crates/horizon-client/src/game/control.rs` (+8 -3) 📝 `docs/benchmark.md` (+18 -0) 📝 `docs/horizon-ctl-commands.md` (+1 -1) ➕ `tests/test_pacing_bench.py` (+28 -0) ➕ `tools/pacing_bench.py` (+242 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What and why `tools/perf_bench.py` measures throughput on short flights. Smoothness needs a different view: every frame of the sessions where players see hitches, and what the slow frames were doing. This PR adds that view, plus what the game needs to report it. - **`tools/pacing_bench.py`:** one fresh game per render distance (seed 1234, creative), driven over horizon-ctl, through these scenarios: - `fly16`: perf_bench's village flight; - `ocean`: perf_bench's ocean flight, Horizon's worst lows on Windows at RD 32; - `fly64`: 1,920 blocks of new terrain at 64 b/s; - `teleport`: 8 teleports of 1,500–3,000 blocks; - `nether`: overworld → Nether → overworld, twice; - `inventory`: the inventory and the pause menu, 20 times each. For each scenario it reports p50, p99, p99.9, max, 1% and 0.1% lows, frames over 33 ms and frames over twice the median, for the frame time and for the frame's CPU time. It also keeps the 12 slowest `HORIZON_SPIKES` lines of that scenario. Options: `--size` gives a small window, so a software renderer (lavapipe) doesn't hide the CPU side; `--env`; `--run N` keeps repeats apart. `--compare A B` prints the A/B tables (median of runs). - **horizon-ctl `stats raw` and `stats reset`:** `stats raw` returns every frame time since the last reset (`frame_ms`, `cpu_ms`, `gpu_ms`), and `reset` starts a new window. The scenarios record exactly their own frames. Help, MCP schema and `docs/horizon-ctl-commands.md` are updated. - **`spans::laps()`:** consecutive steps of one function timed as spans with one `Instant` each, free when `HORIZON_SPIKES` is off. `entity_geometry` (`eg_*`) and `draw_frame` (`r_*`) use it, so a slow frame says which step was slow. This is how the 41 ms first-leash-knot bake (#6656) and the 14 ms buffer frees (#6687) were found. - **`docs/benchmark.md`:** a "Frame pacing" section. Players see no change: the laps cost nothing unless `HORIZON_SPIKES` is set, and `stats` without `raw` answers as before. ## Measured Tooling. Its first runs found #6656 and #6687, and it measures #6698. ## Checks **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at 4bc8e359c, 8 min 34 s) | Check | Result | | --- | --- | | Scope | ✅ 9 files, +373 −5 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 600 passed (4 min 12 s) | | rustfmt | ✅ (9 s) | | clippy | ✅ (51 s) | | tests: horizon-client, horizon-client-lib, horizon-client-render | ✅ 2917 passed (3 min 4 s) | | doc tests | ✅ 0 passed (9 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 | ➖ 132 affected, to run in CI (--quick): ambient_sound, armor_stand_frost, arrow, arrow_wind_charge, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, block_tint and 120 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | `tests/test_pacing_bench.py` checks the statistics against hand-computed values: percentiles, the lows as the mean of the slowest 1% and 0.1%, and the hitch counts. `spans::tests::laps_time_consecutive_steps` checks that laps split one function's time into its steps. 🤖 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:32:39 +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#7043
No description provided.