Repository navigation
chore: Performance benchmark harness - #10787
Conversation
- Table sorting, filtering, and clearing filters. - Row/select-all checkboxes, cell menus and dialogs, and focus restoration. - Keyboard and pointer navigation in ComboBox and Select with rich options.
- Variable-height virtualization: mount, scroll, and resize. - Collection changes: append, delete selected records, and replace datasets. - Tree interactions: expand, navigate, and collapse.
- Only check layout-reading completion conditions (scroll position, variable-height geometry) once per animation frame, so the check no longer forces synchronous layout while table.scroll is being timed. - Write results.json even when building the report fails, and record the run as failed instead of losing its samples. - Mark the report rewritten after each block as in progress, not failed. - Report --trace failures and interruptions separately, without invalidating completed measurements. - Show "n/a" instead of "undefined%" when the base median is 0.
- Add perf/drivers.mjs, which groups each scenario's setup, spec, and checks by fixture and action (table.scroll → drivers.table.actions.scroll). Previously this logic was spread across runner.mjs as branches on scenario IDs. - Make the runner's setup and measurement steps generic. Measured input now comes from the spec's event, target, key, and wheel settings instead of hard-coded scenario IDs. ComboBox filtering keeps its own input routine. - Use one check for both scroll scenarios: all 12 wheel events and at least 10 frame intervals. table.scroll now also requires every wheel event. - Add driver tests checking that every scenario has a driver, every driver is listed in scenarios.mjs, and specs can be passed to the page. - Add drivers.mjs to the harness hash and a short "Adding a scenario" README section.
…en gesture - Have Chromium drive scrolling with Input.synthesizeScrollGesture: 4,000 px at 2,000 px/s, with wheel events generated at the browser's frame rate. This replaces 12 Node-driven wheel steps with 32 ms pauses, whose idle gaps hid jank: at 4x CPU, table.scroll misses about 12% of frames that the old input didn't show. Each trial now collects about 240 frame intervals instead of about 54. - Require each scroll to reach its distance, receive a stream of wheel events, and collect frame intervals covering at least 90% of the gesture, so heavy jank still produces a score instead of failing the run. Remove the unused eventCount option. - Compare scroll scenarios on frameMean, the average frame-callback interval. frameP95 jumps between whole frame periods once some frames are late. In 8-block A/A runs it varied by up to 6.35 ms (39%) at 4x CPU, versus at most 0.32 ms (3.5%) for frameMean. - Keep frameP95 as a supporting report column, and add a missed-frames estimate per trial. - Lower the --frame-threshold default from 2 ms to 0.25 ms, so the 5% relative threshold applies at normal display rates (about 0.42 ms at 120 Hz). Every A/A run on an M2 Max came out within threshold at 1x and 4x CPU. - Update the README and add tests for missed frames and frameMean comparisons.
- Compare each browser launch with itself: its change is the candidate's median trial minus the base's, so drift between launches cancels. Report the Hodges–Lehmann estimate of those changes and an exact Wilcoxon signed-rank interval at the smallest confidence of at least 95% (96.1% for 8 blocks), shown next to the interval. Fewer than 6 blocks stays inconclusive. This replaces the pooled-trial bootstrap, which simulated A/A runs showed was too narrow without launch drift (7–10% false exclusions at a nominal 5%) and too wide with it. The new intervals stay at or below their nominal rate in both cases. - Keep base and candidate pages open side by side and alternate their trials within each block in ABBA order, alternating which arm leads between blocks. Record each sample's position, and bump the results schema to 2. - Require an even --blocks for compare, calibrate, and validate so each arm leads equally often. - Add `yarn perf validate --build <name> --runs <n>`, which runs repeated A/A comparisons with different seeds and reports how often intervals excluded zero, versus the expected rate and the binomial chance of seeing at least that many. - Add tests for the interval maths, simulated A/A error rates with and without launch drift, binomial tails, and the report's confidence column. Update the README, including the scroll threshold calibration recomputed with the new intervals.
- Add a "Changes by browser launch" table to compare reports. For each scenario it shows each launch's paired change (candidate median minus base median), which arm led that launch's ABBA trials, medians over base-led and candidate-led launches, and each launch's start time. This makes drift, order effects, and single outlier launches visible. - Shuffle scenario order separately for each launch with a seeded shuffle, replacing the one-position rotation that left most scenarios at similar positions. Record each scenario's position and start time in the results order. - Add `yarn perf confirm --results <id> --runs <n>`. It reruns scenarios from a completed compare with the same builds and settings but new seeds, by default the ones that reported an improvement or regression. The run count is fixed before any run starts, and every run completes. The summary puts each rerun beside the original and marks the scenario confirmed, not confirmed, or unresolved. - Update --seed help and the README, add a confirm step to "Comparing a change", and add tests for the shuffle, the per-launch table, and confirm verdicts.
- Count DOM mutations per trial: mutation records, plus nodes added and removed, from the input until the rendering opportunity. Report the median per arm. Counts repeat exactly between trials, so a difference between arms shows the DOM work changed even when times are within noise. - Mark the measurement window in diagnostic traces with User Timing measures (`bench:window` and `bench:ready`), so the DevTools Timings track shows what the score covered. Only --trace reruns add them. - Run the same warmups before each traced trial as before measured trials. Previously traces captured a cold first trial. - Add trace.mjs, which splits the renderer main thread's time inside the window into script, style, layout, paint, GC, and other work using innermost-event self time, and counts style and layout forced from script. Show it in a "Diagnostic traces" report table, and record task boundaries (`toplevel`) so scheduling overhead appears as other work. - Add tests for the trace breakdown and the new report sections, and document traces and mutation counts in the README.
|
Lmao, I guess we both got fed up with reviewing at roughly the same time! This is awesome ❤️ |
|
Build successful! 🎉 |
- `table-measured.mount` — mount a virtualized 1,000-row table with measured heights and wrapping labels. - `table-measured.narrow` — narrow the labels column and measure row growth. - `table-measured.widen` — widen the labels column and verify rows shrink. - `table-measured.other-column` — resize another column while measured rows remain tall. - `table-measured.container` — narrow the table container and verify column widths and row geometry settle. - `table-data.focus` — keyboard cell navigation without selection. - `table.scroll-deep` — scrolling after traversing 4,000 rows. - `table-measured.resize-animation` — continuous width changes scored by frame cadence. - `dnd.modality-type` — typing after pointer input, plus `dnd.type` as a keyboard-mode baseline.
Remove or replace: - Remove `form.dialog`; `table-cells.dialog` covers the same modal and autofocus path against a larger DOM. - Replace `select.keyboard`, which repeated `listbox.focus`, with `select.choose`: Enter saves a controlled value, closes the 500-option popup, and returns focus to the trigger. Change: - `table-measured.container` and `resize-animation` start from fitted labels that share the flexible width, so narrowing the container rewraps labels and re-measures rows instead of only shrinking an empty column. - Split `combobox.filter` into single keystrokes: `filter` types `9`, and the new `combobox.narrow` types a second `9` after the first filter settles. This removes the fixed 75 ms pause from the window. - Add `variable.scroll-deep`, which traverses 160,000 px before the measured scroll. Keep `table.scroll-deep`, which scores well above the shallow scroll. - `calibrate` now also adds 16 ms of work to keydown/pointerover dispatch (`listbox.focus`, `select.hover`) and 4 ms to every scroll frame (`table.scroll`, `variable.scroll`); the report says what was added. - Label `dnd.type` as the baseline for `dnd.modality-type`. - Document that `frameMean` cannot fall below the display refresh period, so it detects only work that delays frames.
- `table-measured.resize-drag`: drag the labels column resizer 200 px narrower in 2 px steps, scored by frame cadence. Widths stay controlled through `onResize`. - `reorder.drag-start`, `reorder.drag-move`, `reorder.drop`: keyboard drag, move, and drop in a 200-item GridList that uses `useDragAndDrop`. Pointer drags are not covered because Playwright emulates native drag events. - `table.select-all` and `table.select-range`: Ctrl/Cmd+A over 10,000 virtualized rows, and a shift-click that selects a 4,001-row range. The table now reports its selection size. - `combobox-virtual.open`, `.filter`, `.keyboard` and `select-virtual.open`, `.choose`: 10,000 options in virtualized popups with fixed 52 px rows. - `infinite.scroll`: scroll a virtualized table that appends 50-row pages through `TableLoadMoreItem`, scored by frame cadence. - `table-cells.mount`: mount 100 rows, each with a checkbox, menu, and dialog trigger. - Add an action `cleanup` hook to the runner. Reorder trials use it to cancel an unfinished drag, because drag state is global and survives the fixture remount.
|
Build successful! 🎉 |
|
Build successful! 🎉 |
Agent Skills ChangesModified (9)
InstallReact Spectrum S2: React Aria: |
LFDanLu
left a comment
There was a problem hiding this comment.
Tried it myself on #10768, seems pretty handy. Any particular inspiration on the approach? The scenarios and drivers seems quite through, any ideas on how we'd keep them up to date to include new cases/components/interactions/etc?
snowystinger
left a comment
There was a problem hiding this comment.
Happy to get in for initial usage.
It's a little hard to follow how all of it hangs together through scenarios. Maybe we can have an architecture diagram somewhere that describes it.
No one place specifically, but I wanted to try to cut out as much noise as possible and capture the metrics that end users would actually notice if we improved. It seems like a lot of the benchmarks I've seen use jsdom, development React, or have some other quirks that make them not as useful. I think the environment and the metrics we capture should help with that. This resource was pretty useful: https://web.dev/articles/user-centric-performance-metrics Some of the statistical concepts took some inspiration from this project from Google: https://github.com/google/tachometer And the initial scenarios are inspired by our existing reported performance issues.
I was thinking for future ones, agents could just create one-off scenarios where needed, and we could save them if they seemed useful to keep. |
|
Is there a summary of what scenarios are covered and what is being measured? |
|
Excerpts from the README: ScenariosExample:
See scenarios.mjs for all scenario descriptions. Primary MetricsLower values are better for both primary metrics:
Supporting Metrics
|
This adds a benchmark suite for measuring performance in ways that actually affect user experience: how fast components appear, how quickly interactions update the screen, and how smoothly collections scroll. Some proposed changes may, for instance, reduce re-renders or cut out work in specific narrow cases, but we'd rather be able to measure if changes have a perceivable impact in real-world scenarios.
Benchmarks run production React builds in Chromium (via Playwright) against realistic interactive fixtures. The initial suite includes 60 scenarios covering mounting, keyboard and pointer navigation, filtering, sorting, large selections, keyboard drag and drop, incremental loading, virtualized scrolling, column and container resizing, collection updates, forms, menus, and dialogs. It is intended to be run locally where you can have an agent compare potential changes against a baseline. Builds and results are git-ignored and there is currently no CI integration, although we could use this for regression tests in CI in the future if we wanted to. Everything in this PR is self-contained in
perf/.The harness supports:
yarn perf confirmcommand to check whether improvements or regressions hold across additional runs.Interaction measurements capture the time from input through the expected state change and a rendering opportunity. Scrolling uses browser-driven gestures and measures the average interval between main-thread animation-frame callbacks, with tail intervals and estimated missed callbacks reported as supporting measurements. Diagnostic traces and Long Animation Frames help explain where time was spent, while DOM mutation counts show changes in DOM work.
See
perf/README.mdfor more details. This is also the guidance that agents will use.Example run results:
Potential future improvements:
✅ Pull Request Checklist:
📝 Test Instructions:
Ask your agent to try it out on some performance-related PRs or changes. See
perf/README.mdfor more details.🧢 Your Project: