Draw the champion table and the charts more cheaply (#31) #40

Merged
nessar merged 2 commits from perf/31-full-frame-under-2ms into main 2026-11-17 22:39:00 +01:00
Owner

Part of #31. It makes a full frame of the statistics page a third cheaper. The ticket stays open: budget 1 (2 ms at the 99th percentile) is still over even on the desktop, and the reference laptop has to be measured.

What changes

  • crates/app/src/champion_table.rs: the champion table is the app's own view instead of gpui-component's DataTable.
    • It is a GPUI uniform_list of rows with one plain element per cell. DataTable gave each row a horizontal virtual list, laid out each cell as its own root, and rendered a row's first cell twice.
    • It keeps sorting by header click (descending, ascending, then the default order), scrolling with a scrollbar, stripes, hover, the empty message, and the Attempts column only in a Season.
    • Click-to-select now follows the champion through sorts, filters and reloads; DataTable kept a row index.
    • Dragging column edges, arrow-key selection and screen-reader table roles go, as decided on #31.
    • In a narrow window, columns shrink and clip their text, leaving room for the scrollbar. An ellipsis cost 0.2 ms per frame, so there is none.
  • crates/app/src/stats_page.rs: the charts row is a cached view, ChartsRow, 206 px high.
    • Hovering a row redraws the page, but no longer paints the charts again.
    • ChartsRow::set notifies only when the charts change, since reloads keep coming during an import.
    • A structural test, hovering_the_table_does_not_render_the_charts, guards the cache. It opens the real page, hovers table rows, and checks that the charts were not rendered again while the table was notified. Without .cached(...) it fails: 7 renders instead of 3.
  • crates/app/Cargo.toml, Cargo.lock: GPUI's own test-support (gpui-pre =0.3.12, the version gpui-kit pins) as a dev-dependency, for the test.
    • The lock only gains dev-only crates (proptest, criterion…). Existing versions are unchanged; release builds don't get test-support.
    • gpui-kit's own test-support was not usable: its weak gpui-fast? features would force older wgpu, unicode-properties and others into the lock.
  • docs/performance.md: budget 1 keeps its limit and its reference-machine value.
    • The desktop numbers are recorded for information under the table.
    • A note says the charts row is the page's cached view, and which parts can be one.

Measurements: desktop, for information only

Machine: Ryzen 7 7800X3D, RX 7800 XT, 3840x2160 @ 240 Hz, window 1920x1290 px at 150 %, not the reference laptop.

Release build with --features profile, drawing a full frame Hover p50 / p99 Moves p50 / p99
main 2.27 / 3.61 ms 2.37 / 3.72 ms
this branch 1.47 / 2.30 ms 1.57 / 2.50 ms

Presentation adds a fixed 0.22 ms.

With plain release builds and the probes:

  • Hovering: UI-thread CPU went from 67 % to 37–51 %, and HOVER ping p99 from 2.81 to 1.74 ms.
  • Moving: CPU went from 64 % to 39 %, and MOVE ping p99 from 3.03 to 1.9 ms.
  • Idle CPU and memory are unchanged.

The breakdown of the new frame and the reading are on #31.

Checks

  • cargo.exe fmt and cargo.exe clippy --locked -p arena-tracker --all-targets, with and without --features profile: OK.
  • Core: cargo fmt --check, cargo clippy --locked -- -D warnings, cargo test --locked: OK.
  • cargo.exe test --locked -p arena-tracker: 16 passed. cargo test --locked in WSL: 137 passed.
  • Screenshots of the page at its default size look the same as before. In a 885 px wide window, the columns shrink and the scrollbar doesn't cover the last one.
  • /code-review (standards and spec), with its findings addressed:
    • the scrollbar covering the last column in a narrow window;
    • the doc's wording;
    • ChartsRow::new/set and StatsPage::in_season;
    • a shared test helper;
    • comments on the GPUI pin and on where the test runs.

Limits and findings

  • No icons render anywhere in the app, before and after this change: no sort arrows, no select chevrons. main.rs starts gpui_kit::application() without registering gpui-kit's assets (.with_assets(...)). That is a separate fix, and it will add the icons' small drawing cost.
  • Hover numbers vary by about ±8 % from run to run on the desktop in use.
  • ADR-0002 lists "the data table" among gpui-kit's reasons, and the app no longer uses it.
  • Not checked by hand in the running app: sorting, selection, filters and the reload after an import. Each is covered by the code paths reviewed and by unit tests where one applies.

To do on the reference laptop: the move and hover probes on main and on this branch, then either confirm budget 1 or record its floor (#31).

🤖 Generated with Claude Code

Part of #31. It makes a full frame of the statistics page a third cheaper. The ticket stays open: budget 1 (2 ms at the 99th percentile) is still over even on the desktop, and the reference laptop has to be measured. ## What changes - **`crates/app/src/champion_table.rs`**: the champion table is the app's own view instead of gpui-component's DataTable. - It is a GPUI `uniform_list` of rows with one plain element per cell. DataTable gave each row a horizontal virtual list, laid out each cell as its own root, and rendered a row's first cell twice. - It keeps sorting by header click (descending, ascending, then the default order), scrolling with a scrollbar, stripes, hover, the empty message, and the Attempts column only in a Season. - Click-to-select now follows the champion through sorts, filters and reloads; DataTable kept a row index. - Dragging column edges, arrow-key selection and screen-reader table roles go, as decided on #31. - In a narrow window, columns shrink and clip their text, leaving room for the scrollbar. An ellipsis cost 0.2 ms per frame, so there is none. - **`crates/app/src/stats_page.rs`**: the charts row is a cached view, `ChartsRow`, 206 px high. - Hovering a row redraws the page, but no longer paints the charts again. - `ChartsRow::set` notifies only when the charts change, since reloads keep coming during an import. - A structural test, `hovering_the_table_does_not_render_the_charts`, guards the cache. It opens the real page, hovers table rows, and checks that the charts were not rendered again while the table was notified. Without `.cached(...)` it fails: 7 renders instead of 3. - **`crates/app/Cargo.toml`, `Cargo.lock`**: GPUI's own `test-support` (`gpui-pre =0.3.12`, the version gpui-kit pins) as a dev-dependency, for the test. - The lock only gains dev-only crates (proptest, criterion…). Existing versions are unchanged; release builds don't get `test-support`. - gpui-kit's own `test-support` was not usable: its weak `gpui-fast?` features would force older `wgpu`, `unicode-properties` and others into the lock. - **`docs/performance.md`**: budget 1 keeps its limit and its reference-machine value. - The desktop numbers are recorded for information under the table. - A note says the charts row is the page's cached view, and which parts can be one. ## Measurements: desktop, for information only Machine: Ryzen 7 7800X3D, RX 7800 XT, 3840x2160 @ 240 Hz, window 1920x1290 px at 150 %, not the reference laptop. | Release build with `--features profile`, drawing a full frame | Hover p50 / p99 | Moves p50 / p99 | | --- | --- | --- | | main | 2.27 / 3.61 ms | 2.37 / 3.72 ms | | this branch | 1.47 / 2.30 ms | 1.57 / 2.50 ms | Presentation adds a fixed 0.22 ms. With plain release builds and the probes: - **Hovering:** UI-thread CPU went from 67 % to 37–51 %, and `HOVER ping` p99 from 2.81 to 1.74 ms. - **Moving:** CPU went from 64 % to 39 %, and `MOVE ping` p99 from 3.03 to 1.9 ms. - Idle CPU and memory are unchanged. The breakdown of the new frame and the reading are on #31. ## Checks - `cargo.exe fmt` and `cargo.exe clippy --locked -p arena-tracker --all-targets`, with and without `--features profile`: OK. - Core: `cargo fmt --check`, `cargo clippy --locked -- -D warnings`, `cargo test --locked`: OK. - `cargo.exe test --locked -p arena-tracker`: 16 passed. `cargo test --locked` in WSL: 137 passed. - Screenshots of the page at its default size look the same as before. In a 885 px wide window, the columns shrink and the scrollbar doesn't cover the last one. - `/code-review` (standards and spec), with its findings addressed: - the scrollbar covering the last column in a narrow window; - the doc's wording; - `ChartsRow::new`/`set` and `StatsPage::in_season`; - a shared test helper; - comments on the GPUI pin and on where the test runs. ## Limits and findings - **No icons render anywhere in the app, before and after this change**: no sort arrows, no select chevrons. `main.rs` starts `gpui_kit::application()` without registering gpui-kit's assets (`.with_assets(...)`). That is a separate fix, and it will add the icons' small drawing cost. - **Hover numbers vary by about ±8 % from run to run** on the desktop in use. - **ADR-0002 lists "the data table" among gpui-kit's reasons**, and the app no longer uses it. - **Not checked by hand in the running app**: sorting, selection, filters and the reload after an import. Each is covered by the code paths reviewed and by unit tests where one applies. To do on the reference laptop: the move and hover probes on main and on this branch, then either confirm budget 1 or record its floor (#31). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
nessar added 1 commit 2026-11-17 22:17:58 +01:00
Draw the champion table and the charts more cheaply (#31)
CI / core (pull_request) Successful in 1m12s
8318a5875e
The champion table is now the app's own view, a uniform_list with one
plain element per cell, instead of gpui-component's DataTable, which
gave each row a horizontal virtual list and each cell its own layout,
id and accessibility node. A full frame of the statistics page costs a
third less: on the manual checks machine, drawing it went from 2.37 to
1.57 ms at the median and from 3.72 to 2.50 ms at the 99th percentile.
Sorting by header click, scrolling, click-to-select (now following the
champion through sorts and reloads), stripes and hover stay; dragging
column edges, arrow-key selection and screen-reader table roles go.
Columns shrink with a narrow window, clipped, with room left for the
scrollbar; an ellipsis cost 0.2 ms per frame.

The charts row is a cached view of fixed height, so hovering a row no
longer paints the charts again (about 0.1 ms at the median, 0.2 ms at
the 99th percentile). A structural test guards it, with GPUI's own test
support as a dev-dependency.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nessar added 1 commit 2026-11-17 22:38:36 +01:00
Give a part of the page its own view only for a reason (#31)
CI / core (pull_request) Successful in 1m11s
CI / core (push) Successful in 40s
e1ff92185a
#31 measured that an uncached child view renders again with its parent
and saves nothing, and that caching the charts saved about 0.1 ms per
hovered frame and nothing on window moves. A part gets a view when it
owns state that changes on its own, or as a measured, tested cache;
other parts render as functions in their parent's render.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nessar merged commit e1ff92185a into main 2026-11-17 22:39:00 +01:00
nessar deleted branch perf/31-full-frame-under-2ms 2026-11-17 22:39:01 +01:00
Sign in to join this conversation.