Add a hover probe and a profile build to break down a frame (#27) #37

Merged
nessar merged 1 commits from perf/27-hover-probe-frame-breakdown into main 2026-11-17 20:14:44 +01:00
Owner

Part of #27. It delivers the hover probe, its documentation and the profile build. The breakdown measured with them is below. The ticket stays open until that breakdown is measured on the reference laptop.

What changes

  • scripts/hover-probe.ps1 (new, built on the move probe's structure).
    • It posts synthetic WM_MOUSEMOVE messages across the champion table's rows, 240 per second, without moving the real cursor. Each move changes the hovered row.
    • It reports HOVER cpu against IDLE cpu, and HOVER ping: how long input waits behind the UI thread.
    • It prints Machine: and Build: like the move probe. It is DPI-aware, so its coordinates are in physical pixels.
  • A profile Cargo feature (crates/app), off by default. Normal builds compile none of it, apart from a shown() helper that is the constant true. It enables gpui-kit's profiler, without modifying GPUI (ADR-0004).
    • ARENA_TRACKER_PROFILE=<file.csv>: every second, the app appends the frames drawn (total, request_layout, prepaint, paint), their presentation, and the views' own time (recorded by GPUI from 0.5 ms).
    • ARENA_TRACKER_HIDE=header,banners,tiles,placements,completed,attempts,tabs,table: removes parts of the page, so that a part's cost is measured by removal. The charts keep their height.
  • docs/performance.md: the hover probe and the profile build are documented under "Measuring". The budgets are unchanged.
  • Cargo.lock: additions only (hdrhistogram, and gpui-fast* through gpui-kit's weak gpui-fast?/profiler). They are only built with --features profile, and gpui-fast never is.

Checks

  • cargo fmt --all --check: OK
  • cargo.exe clippy --locked -p arena-tracker --all-targets -- -D warnings: OK, both with and without --features profile
  • cargo.exe test --locked -p arena-tracker: 11 passed
  • The hover probe was run on Windows against the real app: 240 moves/s achieved. The CSV was produced by the profile build.
  • An independent review (Claude Opus) and /code-review (standards and spec) found nothing blocking. Their remarks are taken into account in the doc and listed under Limits.

Breakdown of a full frame: desktop, for information only

These were taken on the desktop (Ryzen 7 7800X3D, RX 7800 XT, 3840x2160 @ 240 Hz, window 1920x1290 px at 150 %), which is not the reference laptop, while the PC was in use. The build is a release build with --features profile, so the times come from GPUI's profiler. Each run: real data, game client closed, 15 s of loading, then the hover probe with 5 s idle and 5 s of hovering. The frames analysed are the 5 s of hovering.

Variant (ARENA_TRACKER_HIDE) Frames/s Frame p50 / p99 request_layout prepaint paint present Hover CPU
main without profiler (reference) – – – – – – 73 %
full page 240 2.16 / 2.77 0.31 0.95 0.79 0.22 65 %
without the 3 charts 239 2.12 / 2.77 0.34 1.18 0.49 0.18 67 %
without the table 48 0.89 / 1.25 0.19 0.25 0.46 0.20 5 %
without tiles and banners 240 2.40 / 2.99 0.31 1.15 0.83 0.23 56 %
without header and tabs 240 2.06 / 2.55 0.21 1.00 0.77 0.22 50 %

All times are in ms. The phase columns are p50 values.

Reading

  • Champion table: about 1.3 ms of the 2.2 ms frame (60 %), mostly in prepaint. GPUI attributes 0.63 ms of prepaint per frame to the table view alone. It is the first part to reduce.
  • Three charts: about 0.3 ms, all of it paint (0.79 → 0.49 ms).
  • Header (drop-downs, buttons) and tabs: about 0.1 ms of layout (0.31 → 0.21 ms).
  • Tiles and banners: within the noise.
  • Presentation: a fixed 0.2 ms per frame (present, i.e. GPUI and DirectX submitting the frame). The app cannot reduce it.
  • Text layout and shaping cannot be isolated by removal. GPUI reuses the lines shaped in the previous frame, so the cost of shaping spreads over each part. A sampling profiler would be needed.
  • First to reduce to reach 2 ms on the laptop (5–7 ms per frame there):
    1. What the table rebuilds on each hovered row.
    2. Redrawing everything else on each hover. Nothing on the page is a cached view today, so hovering one row also rebuilds the charts, tiles and header, about 0.9 ms here.

Limits

  • Hiding parts other than the charts and the table shifts the layout. Hiding the header, banners, tiles or tabs gives the table more height, hence more rows. That underestimates those parts' cost; it is why prepaint went up for "without tiles".
  • Where the real cursor sits matters. If it is outside the window, GPUI sees each synthetic move as an enter followed by a leave, and refreshes the whole window, bypassing cached views. This doesn't affect today's numbers, since nothing is cached, but it would hide the gain from a cached-view fix. The doc says to leave the cursor over the window.
  • About one row per move only holds for a window at least 800 px tall. HOVER achieved says little, because PostMessage doesn't wait.
  • Build: doesn't show whether the exe was built with profile. Profile and normal builds go to the same target\release.
  • Don't measure memory on a profile build: GPUI's timing buffers grow up to 16 MiB per thread.
  • Without a console in release, a CSV that can't be opened fails silently.
  • hover-probe.ps1 repeats about 100 lines of move-probe.ps1. A shared file would be possible if a third probe comes along.

To do on the reference laptop: run the same six variants (commands in docs/performance.md) and record the breakdown on #27.

🤖 Generated with Claude Code

Part of #27. It delivers the hover probe, its documentation and the profile build. The breakdown measured with them is below. The ticket stays open until that breakdown is measured on the reference laptop. ## What changes - **`scripts/hover-probe.ps1`** (new, built on the move probe's structure). - It posts synthetic `WM_MOUSEMOVE` messages across the champion table's rows, 240 per second, without moving the real cursor. Each move changes the hovered row. - It reports `HOVER cpu` against `IDLE cpu`, and `HOVER ping`: how long input waits behind the UI thread. - It prints `Machine:` and `Build:` like the move probe. It is DPI-aware, so its coordinates are in physical pixels. - **A `profile` Cargo feature** (`crates/app`), off by default. Normal builds compile none of it, apart from a `shown()` helper that is the constant `true`. It enables gpui-kit's `profiler`, without modifying GPUI (ADR-0004). - `ARENA_TRACKER_PROFILE=<file.csv>`: every second, the app appends the frames drawn (total, `request_layout`, `prepaint`, `paint`), their presentation, and the views' own time (recorded by GPUI from 0.5 ms). - `ARENA_TRACKER_HIDE=header,banners,tiles,placements,completed,attempts,tabs,table`: removes parts of the page, so that a part's cost is measured by removal. The charts keep their height. - **`docs/performance.md`**: the hover probe and the profile build are documented under "Measuring". The budgets are unchanged. - **`Cargo.lock`**: additions only (`hdrhistogram`, and `gpui-fast*` through gpui-kit's weak `gpui-fast?/profiler`). They are only built with `--features profile`, and `gpui-fast` never is. ## Checks - `cargo fmt --all --check`: OK - `cargo.exe clippy --locked -p arena-tracker --all-targets -- -D warnings`: OK, both with and without `--features profile` - `cargo.exe test --locked -p arena-tracker`: 11 passed - The hover probe was run on Windows against the real app: 240 moves/s achieved. The CSV was produced by the profile build. - An independent review (Claude Opus) and `/code-review` (standards and spec) found nothing blocking. Their remarks are taken into account in the doc and listed under Limits. ## Breakdown of a full frame: desktop, for information only These were taken on the desktop (Ryzen 7 7800X3D, RX 7800 XT, 3840x2160 @ 240 Hz, window 1920x1290 px at 150 %), which is not the reference laptop, while the PC was in use. The build is a release build with `--features profile`, so the times come from GPUI's profiler. Each run: real data, game client closed, 15 s of loading, then the hover probe with 5 s idle and 5 s of hovering. The frames analysed are the 5 s of hovering. | Variant (`ARENA_TRACKER_HIDE`) | Frames/s | Frame p50 / p99 | request_layout | prepaint | paint | present | Hover CPU | | --- | --- | --- | --- | --- | --- | --- | --- | | main without profiler (reference) | – | – | – | – | – | – | 73 % | | full page | 240 | 2.16 / 2.77 | 0.31 | 0.95 | 0.79 | 0.22 | 65 % | | without the 3 charts | 239 | 2.12 / 2.77 | 0.34 | 1.18 | 0.49 | 0.18 | 67 % | | without the table | 48 | 0.89 / 1.25 | 0.19 | 0.25 | 0.46 | 0.20 | 5 % | | without tiles and banners | 240 | 2.40 / 2.99 | 0.31 | 1.15 | 0.83 | 0.23 | 56 % | | without header and tabs | 240 | 2.06 / 2.55 | 0.21 | 1.00 | 0.77 | 0.22 | 50 % | All times are in ms. The phase columns are p50 values. **Reading** - **Champion table: about 1.3 ms of the 2.2 ms frame (60 %), mostly in `prepaint`.** GPUI attributes 0.63 ms of `prepaint` per frame to the table view alone. It is the first part to reduce. - **Three charts: about 0.3 ms, all of it paint** (0.79 → 0.49 ms). - **Header (drop-downs, buttons) and tabs: about 0.1 ms of layout** (0.31 → 0.21 ms). - **Tiles and banners: within the noise.** - **Presentation: a fixed 0.2 ms per frame** (`present`, i.e. GPUI and DirectX submitting the frame). The app cannot reduce it. - **Text layout and shaping cannot be isolated by removal.** GPUI reuses the lines shaped in the previous frame, so the cost of shaping spreads over each part. A sampling profiler would be needed. - **First to reduce to reach 2 ms on the laptop** (5–7 ms per frame there): 1. What the table rebuilds on each hovered row. 2. Redrawing everything else on each hover. Nothing on the page is a cached view today, so hovering one row also rebuilds the charts, tiles and header, about 0.9 ms here. ## Limits - **Hiding parts other than the charts and the table shifts the layout.** Hiding the header, banners, tiles or tabs gives the table more height, hence more rows. That underestimates those parts' cost; it is why `prepaint` went up for "without tiles". - **Where the real cursor sits matters.** If it is outside the window, GPUI sees each synthetic move as an enter followed by a leave, and refreshes the whole window, bypassing cached views. This doesn't affect today's numbers, since nothing is cached, but it would hide the gain from a cached-view fix. The doc says to leave the cursor over the window. - **About one row per move** only holds for a window at least 800 px tall. `HOVER achieved` says little, because `PostMessage` doesn't wait. - **`Build:` doesn't show whether the exe was built with `profile`.** Profile and normal builds go to the same `target\release`. - **Don't measure memory on a profile build:** GPUI's timing buffers grow up to 16 MiB per thread. - **Without a console in release, a CSV that can't be opened fails silently.** - **`hover-probe.ps1` repeats about 100 lines of `move-probe.ps1`.** A shared file would be possible if a third probe comes along. To do on the reference laptop: run the same six variants (commands in `docs/performance.md`) and record the breakdown on #27. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
nessar force-pushed perf/27-hover-probe-frame-breakdown from 64b1d3b621 to 3c504c3b41 2026-11-17 19:47:20 +01:00 Compare
nessar force-pushed perf/27-hover-probe-frame-breakdown from 3c504c3b41 to 00c94cbea1 2026-11-17 20:11:13 +01:00 Compare
nessar added 1 commit 2026-11-17 20:11:32 +01:00
Add a hover probe and a profile build to break down a frame (#27)
CI / core (pull_request) Successful in 42s
CI / core (push) Successful in 1m10s
2c1dde684c
scripts/hover-probe.ps1 posts synthetic mouse moves across the champion
table rows, 240 per second, without moving the real cursor, and reports
the UI thread's CPU and input latency against an idle phase, with the
machine and build like the move probe.

A `profile` Cargo feature, off by default, enables GPUI's profiler: with
ARENA_TRACKER_PROFILE the app appends each frame's phases, presentation
and views' own time to a CSV, and ARENA_TRACKER_HIDE removes parts of
the page so that each part's cost is measured by removal. Normal builds
compile none of it. Both are documented in docs/performance.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nessar force-pushed perf/27-hover-probe-frame-breakdown from 00c94cbea1 to 2c1dde684c 2026-11-17 20:11:32 +01:00 Compare
nessar merged commit 2c1dde684c into main 2026-11-17 20:14:44 +01:00
nessar deleted branch perf/27-hover-probe-frame-breakdown 2026-11-17 20:14:44 +01:00
Sign in to join this conversation.