Skip to content

Give the page benchmarks one home for each reading, and time a live revision, leaving the field and a click's reading on screen - #5546

Merged
max-sixty merged 12 commits into
mainfrom
canonical-benchmark
Nov 5, 2026
Merged

max-sixty merged 12 commits into
mainfrom
canonical-benchmark

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Max asked for canonical benchmarks rather than several slightly different implementations. Every A/B tool already shared one way of picking base and head (arms.choose_arms) and one page generator (scaling.COLLECTIONS), but four readings each had two or more copies, and this week's agents wrote about 5,500 lines of one-off scripts for what leaf-dev scaling couldn't measure. This gives each reading one home and adds the measurements those scripts were written for.

One home each

  • V8 profiles: dev/leaf_dev/profiles.py (cpu_profile records, Profile reads one or several files as one). Bench-latency's Profile/functions, scaling's function_times and both profiler starters are gone.
  • Interleaved rounds and their minimum: scaling.interleaved, scaling.lowest and scaling.measure_rounds, used by the CLI (new --rounds N), the daily browser test, server_scaling.measure and bench-latency's arms. Each round takes every size, and every arm at each size, reversed every other round.
  • The growth check: scaling.failures, replacing server_scaling.failures and the daily test's inline copy.
  • Chromium's metrics read: browser.chromium_metrics, used by scaling's clock, test_render_gate.py and render_harness.live_counts.
  • bench_latency.js moves to dev/leaf_dev/painted.js so scaling shares its painted-frame probe; BUDGET_MS lives only in scaling. bench-check, which nothing used, is deleted.

New in leaf-dev scaling

  • leave: Escape out of the comment field.
  • revision: an agent's live revision, writing index.html with one paragraph under the title and then without it, applied in the open tab.
  • shown: from a click to the first frame painted once the server's reading is presented, the 100 ms budget root AGENTS.md sets, which no tool measured. It is an upper bound, at most a frame late, for goals that stay met once met.
  • Every page in COLLECTIONS now runs in the browser: the messages page's summaries carry the fields admission needs, and a page with no option (boards, cards) reads no click, Tab or shown, which its table names as missing.

Each reading and its profile go through one timed span, so setup such as clicking back into the field stays out of both. The daily test measures the three new transitions and charts them; it holds leave to the growth rule and leaves revision (it grows with the margin's rows today, fit 1.29 on a loaded host, 34% noise on the largest reading would cross 1.5) and shown (elapsed time on a shared runner) out of the assertion, as it already does for Tab. They add about 3 minutes across the daily test's four pages.

Lines against main: production +569/−397 (most of the addition is the three transitions and the rounds), tests +94/−122, docs +3/−1.

Checks: leaf-dev scaling with --rounds 2 in Chromium and Firefox, --profile, three-axis growth, messages boards cards; --server events; bench-latency with --profile; test_scaling.py[prose], test_server_scaling.py[events], the browser live_counts test and the corpus render-gate test by node id; pre-commit. Two independent reviews found the painted probe could count a reading before it painted and that leave's profile included setup; both are fixed. dev/tests fails 17 tests and errors 3 here, none in a module this touches.

This was written by Claude Code on behalf of max-sixty

The daily scaling test failed only growth, so a change that slowed pages of
every size alike passed, and each run's readings were discarded. The test now
writes each axis's lower readings at 64 sections into the test job's artifact,
and a scaling-chart job on the daily schedule appends them to the gh-pages
branch with github-action-benchmark, which charts them and comments on a commit
whose run reads 50% above the one before.
The suite's watches instrument every timer, write and input on a watched page,
so the daily test's readings were mostly the watches: a keystroke at 64
sections read 404 ms on CI's asks page, and 49 ms against 7 unwatched on prose
here. The growth check's exponents carried that overhead too.
…the field, a revision and a click's reading on screen

Max asked for canonical benchmarks rather than several slightly different
implementations. `leaf-dev scaling` was already the harness; four of its
mechanisms had copies, and its gaps sent this week's agents to one-off
scripts. Each now has one home, and every caller moved:

- V8 profiles: `bench_latency.Profile`, scaling's `function_times` (a copy
  of `Profile.functions`) and the two profiler starters became
  `leaf_dev/profiles.py`: `cpu_profile` records one into a `.cpuprofile`,
  and `Profile` reads it back. bench-latency starts its trace before the
  profile, as it did before; started after it, the profile held no samples
  in the trace's window.
- Interleaved rounds with the lowest reading: the scaling test's loop,
  `server_scaling.measure`'s loop and bench-latency's alternating arms
  became `scaling.interleaved` and `scaling.lowest`. The CLI and the
  daily browser test both go through `scaling.measure_rounds`, and the
  server's `measure` through `lowest`. Alternate rounds now run in reverse,
  as bench-latency's did.
- The growth check: `server_scaling.failures` and the scaling test's inline
  copy became `scaling.failures(rows, costs, fitted)`.
- Chromium's performance metrics: scaling's `renderer_clock`, the two reads
  in `tests/journeys/test_render_gate.py` and `live_counts` in
  `tests/render_harness.py` read through `browser.chromium_metrics`;
  `live_counts` collects garbage with Playwright's `request_gc`, which sends
  the same `HeapProfiler.collectGarbage`.
- bench-latency's in-page probe moved, with history, to
  `leaf_dev/painted.js` (`painted.py`), since scaling now uses its
  `delivered` goal too. It counts a pointer click as a gesture's input
  beside Enter, and runs without `main_thread.js`.
- `server_scaling.BUDGET_MS` moved to `scaling.BUDGET_MS`, the one 100 ms.

`leaf-dev scaling` gains:

- `--rounds N`: every page N times, interleaved round > size > arm, the
  lowest reading of each cost reported (default 1, or 3 with `--server`).
  Every page of an axis is served for the whole run.
- `leave`: the CPU of Escape taking the caret out of the comment field,
  which keeps its draft, each from a click back into it, in a window of
  its own.
- `revision`: the CPU of an agent's revision through the real path: the
  page's `index.html` is written with a paragraph under the title, the
  server activates it, and the tab applies it in place; the next takes it
  away.
- `shown`: the time from a click to the first frame painted once the
  server's reading of its event is presented, root `AGENTS.md`'s 100 ms
  budget, read by `painted.js`'s `delivered` goal in clicks of its own,
  after every CPU reading, since arming that goal loads the runtime's
  diagnostics. The table flags it past `BUDGET_MS` at the
  largest size. It is elapsed time: under `taskpolicy -c utility` it read
  110 to 170 ms on pages the default policy showed in 30 to 35.

The daily `tests/journeys/test_scaling.py` reads all three, charts them at
64 sections beside the others, and holds them to the growth rule. They
add about a third to each axis's time: prose took 150 s with the old
transitions and about 200 s with every transition, on this Mac under
`taskpolicy -c utility`, so about 3 minutes across its four axes. Each
new transition costs about what an existing one does. On asks a revision
grew from 47 ms at 8 sections to 1.4 s at 256 in one run, an exponent of
1.29 against the 1.5 the test fails.

`measure` takes the `ServedPage` that `serving_collection` now yields, so
the revision can write its source.

Deleted `leaf-dev bench-check`, which nothing used: nothing in the tree
names it, and every commit to it since #1373 changed it along with the
other tools.

dev/AGENTS.md now points a new page benchmark at `leaf-dev scaling`.
… reading covers, and hold revision and shown to no growth

Three findings from review of the benchmark consolidation:

- `painted.js` read each goal in the task after a frame, so a server answer
  processed between that frame and the read could satisfy `delivered` before
  any frame had painted the new reading. The sampler now reads which goals
  hold in the frame's animation callback, before its paint, and records them
  in the task after it. This changes bench-latency's times as well as
  scaling's `shown`.
- A transition's profile covered its setup while its CPU reading didn't:
  `leave.cpuprofile` held the four clicks back into the field. Every reading
  and its profile now go through one `timed` span in `scaling.measure`, a
  transition's spans each to their own file (`leave-1.cpuprofile`, ...), and
  `Profile` reads several files as one, so the growth report sums the spans.
  `shown`'s profiles cover each click to its paint, not the arming.
- The daily growth check would flake on `revision`, which grows with the
  margin's rows as the runtime places them today (on asks it fit 1.29, and a
  largest reading 34% higher fits 1.51), and on `shown`, elapsed time on a
  shared runner. Both are still measured and charted, and `UNHELD` in
  `tests/journeys/test_scaling.py` leaves them out of the assertion beside
  Tab. `leave` stays held: its exponents ran 0.22 to 0.63.
…e, for goals that stay met

painted.js reads each goal in its animation callback, before the frame's
later callbacks, their microtasks and ResizeObserver delivery, so a goal
those make true counts a frame late. Its header and scaling's description
of shown now say each time is an upper bound at most a frame above first
paint, that the bound needs goals that stay met once met, and which of
bench-latency's goals do: message, card and delivered's event stay;
delivered and revision also wait on presentation, which a later reading
only delays; status stays only while nothing else sets the page's status.
… in the browser

The messages page's summary events had no agent or session, which a
summary's record requires, so admission refused the page and the browser
could never measure it; they now name the agent Codex and the session
scaling.

The boards and cards pages hold no lf-option, and measure aimed its
click, Tab's first stop and shown at the first one, so it failed there.
A page with no option now reads none of those, and the table leaves
them out and names them as missing, so every COLLECTIONS page runs in the
browser.
leaf-agent
leaf-agent previously approved these changes Nov 5, 2026
# Conflicts:
#	dev/leaf_dev/commands/scaling.py
#	dev/leaf_dev/server_scaling.py
#	tests/journeys/test_scaling.py
@max-sixty
max-sixty merged commit 8b6f4f0 into main Nov 5, 2026
5 checks passed
@max-sixty
max-sixty deleted the canonical-benchmark branch November 5, 2026 21:51
max-sixty added a commit that referenced this pull request Nov 6, 2026
…ling and bench-latency (#5576)

Max asked for one benchmark that takes variables, rather than two that
each serve
pages from this tree and a base, drive inputs, time them and profile
them. This
replaces `leaf-dev scaling` and `leaf-dev bench-latency` with one
`leaf-dev bench`,
and deletes both, with every caller cut over and no alias.

```
uv run leaf-dev bench [PAGE ...] [--sizes 32,64,128,256] [--input NAME ...]
    [--read cpu|paint|server ...] [--rounds N] [--base [REF]] [--browser firefox] [--profile]
```

- **The page** is a generated collection (`COLLECTIONS`, measured at
each size beside the
  BASE page) or any example or the corpus by name.
- **The inputs** are one table, `INPUTS`: scaling's click, key, leave,
Tab, wheel and
revision; bench-latency's comment, card move, agent reply, agent status
and stamped
revision (`stamp`); and a triple-click selection of the title
(`select`), which
replaces #5472. A page without what an input needs (an option, a card)
reads none of
  it and the report names it missing.
- **The arms** come from `arms.choose_arms`, as before.
- **What to read**: `cpu` (scaling's CPU pass), `paint` (bench-latency's
time to the
painted result, the POST's answer, the server's reading on screen, and
the requests
and bytes caused), `server` (the in-process server paths,
`server_paths.py`, the
renamed `server_scaling.py`), for this checkout's generated pages only,
as before.
  Default `cpu` and `paint`, and in Firefox `cpu`.

Scaling is the same benchmark over several sizes: with three sizes or
more the table
gives each reading's exponent, marked `!` past 1.5. Every reading of
every page goes in
one table, a row per reading and a column per size and arm, and
`results.json` keeps
each round's readings and the table's lowest (`lowest`), which the daily
chart reads.

## Each measurement's method

Kept as it was:

- CPU: thread ticks (or Firefox's OS count), the load until the main
thread goes quiet,
idle subtraction, the mean over each input's count, per-window `ready`
for inputs that
  need setup, interleaved rounds and the lowest reading.
- Paint: painted.js goals from the input event or the agent's first
write, the POST's
answer by attempt, request attribution against what the page started
while left
alone (starters pooled across rounds), long-frame owners, and
`--profile`'s trace and
  attribution.
- Server: unchanged code.

What changed, each a call Max may reverse:

- **Each pass reads a fresh page.** The CPU pass and the paint pass of
each round each
build and serve the page anew, so no input meets what another pass or
round left on
it. Scaling served one page through every round, and bench-latency's
runs piled up
each other's comments, questions and moves. Each pass pays a page build.
- **The paint pass starts with the panel folded**, as a page loads, and
the reply
opens the views it needs. bench-latency opened the Threads view first, a
habit from
the classic chrome's always-visible thread list (#3100). An open Threads
view slows
the server's reading on screen: a click's `shown` on the asks page at
128 sections
read 59–61 ms with it open and 43–47 ms folded, three fresh pages each,
interleaved.
- **The paint pass times each input as many times as the CPU pass reads
it** (a click
four times, a revision twice, the conversation's inputs once) and keeps
the median,
  as scaling read `shown` over four clicks. Every round's samples are in
  `results.json`.
- **One statistic across rounds: the lowest**, for every reading.
bench-latency
  printed median [min-max] over runs.
- **Both passes open `browser.tab`'s window**, which reduces motion, as
scaling's did;
bench-latency's context used no preference, which may be why a card move
painted
  sooner here (not checked).
- **`revision` saves only**, inserting a paragraph under the title, as
an agent's
ordinary save does (scaling's input inserted and then removed one).
bench-latency's
revision, a save followed at once by `leaf page stamp`, is the `stamp`
input, and
  the note's stamp-route analysis now runs as
  `leaf-dev bench corpus --read paint --input stamp --base`.
- **Targets are found on any page.** The comment selects the first
paragraph after
the title (the triage board's lede, as before; on the corpus its own
lede rather
than the triage lede deep inside it). A move takes the first card with a
column left
of it (`card-tz` on the triage board, bench-latency's first move). The
agent's
thread is a general one, made at the first reply and taken in by the
page before the
reply's window opens; bench-latency anchored one on the triage lede
before the page
loaded. An anchored agent thread made every click on the asks page cost
about 70 ms
more CPU (13 → 82 ms at 8 sections), so it would have changed every
other input's
  reading.
- **Input order**: the page's own inputs, then the two revisions, then
the selection,
then those that add threads and to-dos. A selection standing on the
title holds a
revision back (after a triple click on the title, a save left the page
on its old
  revision for 5 s), so the selection follows the revisions.
- **`--read paint` also counts requests and bytes**, from the same
window, so they
  have no read of their own.
- **`--browser firefox` reads only `cpu`**: the paint pass needs
Chrome's DevTools
  protocol for its requests, and bench-latency ran only in Chromium.
- **The daily run takes every input with the default reads**
(`leaf-dev bench --sizes 64,128,256 --rounds 2`). Its chart is now
"Bench at 64
sections" and holds the load's and each input's main-thread CPU and each
gesture's
`shown` (`asks: click cpu`, `asks: click shown`, ...); request counts
and single
paints stay in the summary, the log and the artifact. `gh-pages` holds
no reading
  yet, so the rename loses nothing.
- **The reply reads its delivery in parts**: on a page seeded with many
events,
the first `leaf wait` delivers them all with the question, in parts (14
on the
threads page at 64 sections). The reply follows each part's `leaf
delivery read
<id> --part N`, as the delivery tells an agent to, and joins their text,
leaving
  the seeded threads queued as the page was generated.
- **`compare_profiles` is gone**: its side-by-side window and render
times repeated
  what the table and each arm's profile already print.
- **Whether an input posts is read from its goals**: an input waits for
its POST's
answer in the CPU pass where its goals include the server's reading of
its event.
Whether it paints stays declared (`Input.paints`), since a run refuses
`--read
paint` with no painting input before it builds a page, and the paint
pass skips an
  input without running its `ready`, whose setup moves the page.

## Equivalence

Old and new on the same page, inputs and sizes, back to back on this
Mac. The old
commands ran from untracked copies of main's `scaling.py` and
`bench_latency.py`.

**CPU, asks page, lowest of two rounds** (`leaf-dev scaling asks prose
--sizes 64,128
--rounds 2` at load 6 against `leaf-dev bench asks prose --sizes 64,128
--rounds 2
--input click --input key --input leave --input tab --input scroll
--input revision` at
load 4), ms at 8 / 64 / 128 sections:

| Reading        | scaling              | bench                |
| -------------- | -------------------- | -------------------- |
| load           | 180 / 388 / 627      | 181 / 404 / 640      |
| click          | 11.8 / 21.2 / 28.0   | 19.8 / 22.7 / 28.5   |
| key            | 4.1 / 4.6 / 5.3      | 5.0 / 5.7 / 4.9      |
| leave          | 11.2 / 28.8 / 48.0   | 16.2 / 30.9 / 40.8   |
| Tab            | 9.0 / 11.5 / 11.0    | 12.4 / 9.4 / 10.9    |
| wheel          | 1.2 / 2.5 / 3.9      | 1.5 / 2.4 / 3.3      |
| revision       | 26.2 / 131.9 / 241.6 | 29.1 / 126.9 / 242.3 |
| event          | 4.9 / 7.8 / 10.5     | 6.6 / 8.5 / 10.5     |
| click `shown`  | 28.4 / 28.7 / 29.3   | 29.8 / 30.9 / 32.7   |

The prose page reads alike (load 146 / 159 / 172 against 147 / 158 /
168, revision 12.6
/ 23.3 / 36.6 against 15.5 / 27.9 / 39.6). A click at 8 sections spreads
from 11 to 21
ms between passes on one served page (`cpu_pass` three times on each of
two pages read
14.0, 11.4, 16.9 and 18.7, 21.4, 11.8), so its 19.8 is one pass's draw.

Two readings sit consistently above scaling's, here and in an
independent A/B: `shown`
by about 2 ms, and `leave` at 64 sections by about 3 ms. For `shown`,
the likely cause
is a colder page: scaling clicked for `shown` after its whole CPU pass,
and here the
first of four clicks on a fresh page reads 40–46 ms and the rest 29–33.
The paint tab's
instrumentation isn't it: with and without Chrome's network domain and
the long-frame
observer, three fresh pages each, the medians were 31.7–32.2 and
30.6–32.7 ms. A quick
look found no cause for `leave`.

**Paint, triage board, three rounds** (`leaf-dev bench-latency --page
triage-board
--runs 3` against `leaf-dev bench triage-board --read paint --rounds 3
--input comment
--input move --input reply --input status --input stamp`, both at load
4), median
[min–max] ms over the runs:

| Input | bench-latency painted | bench painted | bench-latency Sent |
bench `shown` | requests, KB |
| ----------------- | --------------------- | ------------- |
------------------ | ------------- | -------------------- |
| comment | 51 [49–89] | 73 [71–76] | 66 [66–89] | 93 [92–96] | 1, 5.5 /
1, 5.4 |
| move | 11 [10–21] | 11 [10–14] | 32 [26–45] | 33 [32–35] | 1, 6.2 / 1,
6.1 |
| reply | 94 [55–176] | 68 [62–72] | | | 2, 4.6 / 2, 4.5 |
| status | 79 [56–91] | 110 [91–115] | | | 1, 1.5 / 1, 1.7 |
| revision / stamp | 234 [228–277] | 251 [248–264] | | | 2, 160 / 2, 147
|

The comment and status differ because every bench round reads a fresh
page, so each
is the page's first: bench-latency's first run read the comment at 89
ms, the status
at 91 and the move at 21, and its later runs, on a page that already
held them, 49–51,
56–79 and 10–11. The panel's state doesn't explain the comment: with the
Threads view
open and folded, three fresh pages each, it painted in 73 and 72 ms; the
status read
93 and 114. The stamped revision's bytes differ because it now inserts a
paragraph
where bench-latency's appended words to the lede.

**Server paths** (`leaf-dev scaling --server events options --sizes
128,256` against
`leaf-dev bench events options --read server --sizes 128,256`): the same
code, reading
within 0.5 ms on every path (append on events 1.7 / 6.9 / 12.1 against
1.9 / 7.1 /
12.1).

**Selection** (`leaf-dev bench asks document --sizes 512 --input select
--read
cpu`): 24.9 → 159.2 ms on asks and 31.9 → 45.0 on document, from 8 to
512 sections;
#5472 read 26 → 152 and 32 → 40 on main.

## Callers

`.github/workflows/ci.yaml` (the daily job is now `bench`, charting the
load's and
each input's CPU and each gesture's `shown` at 64 sections: the readings
it charted
under new names, less the server's `event` time and size, plus the new
inputs' CPU
and the comment's `shown`), root `AGENTS.md` ("Responsiveness" names the
command),
`tests/AGENTS.md` (the rule #5522 wrote names it), `dev/AGENTS.md`,
`browser/AGENTS.md`, `notes/user-feedback-responsiveness.md`,
`notes/shift-watch-cost.md`, and comments in `floating.js`, `toc.css`,
`test_interact_layer.py`, `painted.js/py`, `main_thread.py`,
`profiles.py` and
`browser.py`.

## Size and checks

`bench.py` is 2,175 lines where `scaling.py` and `bench_latency.py` were
2,241 together;
the whole change is +2,257 / −2,315. The two commands shared little code
after #5546
(arms, painted.js, profiles), so the saving is one CLI, one
orchestration and one report
in place of two; what this buys besides is every input on every page,
every read on
every input, and one place to add the next.

The daily job's two steps ran locally at one round and exited 0:
`uv run leaf-dev bench --sizes 64,128,256 --rounds 1` in 723 s at load
6–7 over asks,
document, prose and threads, and `uv run leaf-dev bench --read server`
in 163 s; the
chart step's `jq` over their `results.json` gave 56 series (`asks: load
cpu` 468.91
ms, ...). The rows page #5567 added, now in `COLLECTIONS` and `AXES`,
ran alone in
168 s at load 4–5 (`leaf-dev bench rows --sizes 64,128,256 --rounds 1`,
exit 0) and
adds 14 series, so the chart holds 70. The job runs two rounds of all
five pages, so
expect about 30 minutes on this Mac under its 120-minute guard.

Also run on this Mac: the equivalence runs above; `--profile` (asks at
16 and 32, the
CPU growth listing and the paint attribution); `--base` (triage-board's
move and
status on the merge base and the head); `--browser firefox`, whose
default read is
`cpu`; `--read paint --input move --input click` on asks, which names
move missing;
the reply on threads and messages at 64; the refusals of `--read paint`
with no
painting input, of `--read server` with `--base` or an authored page, of
Firefox with
`--read paint` or `--profile`, and of an unknown PAGE; `uv run
pre-commit run` on
every changed file, including `ty`, `vulture` and `actionlint`.

Not verified: the corpus page; WebKit, which the command refuses as
before.

Supersedes #5472.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants