Skip to content

Time a selection in leaf-dev scaling, and hold it to a budget on a large page daily - #5472

Closed
max-sixty wants to merge 1 commit into
mainfrom
grind/scaling-select
Closed

max-sixty wants to merge 1 commit into
mainfrom
grind/scaling-select

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

leaf-dev scaling timed a click, a key, Tab and a wheel step, and never made a
selection, so the daily scaling suite couldn't see #5441's bug, where every selection
change tested each of the page reading's segments. It now also times a triple click on
the page's title, the gesture a user makes to comment on a line. The selection comes
last among the inputs, so a selection left on the page changes no other input's work.

A walk of the page for each selection grows only linearly, and the daily growth check
fails only exponents past 1.5. With #5441's runtime change reverted, the selection's
growth fits exponents of 0.97 to 1.03 and passes that check. So a selection is also held
to a budget at REFERENCE (512): 100 ms of main-thread time (SELECT_BUDGET_MS,
scaling.over_budget). A selection's fixed work already takes longer than the frame
root AGENTS.md gives a gesture's own result, so the budget is the 100 ms in which that
rule puts the server's reading on screen. leaf-dev scaling names a selection over it
on a run whose sizes include 512, and the new daily test
test_a_selection_fits_its_budget_on_a_large_page fails it on each browser page.

Evidence

Select ms at 8 and 512 from uv run leaf-dev scaling --sizes 512 --base REF, where REF
is main with #5441's change to browser/runtime reverted, built as a commit object from
git apply --cached -R on a scratch index:

Page #5441 reverted main
document 68 → 1,602 32 → 40
asks 31 → 427 26 → 152
prose 26 → 140 23 → 30
threads 41 → 60 26 → 45

On the reverted base the command prints select: a selection takes 1623 ms at 512, over 100 ms under the document table, and 141 ms under the prose table. At sizes 8, 64, 128
and 256 on that base, the selection's growth fits exponents of 0.97 (document), 0.99
(asks) and 1.03 (prose), linear growth the 1.5 check passes.

The daily tests, run on this branch with uv run pytest tests/journeys/test_scaling.py -k <name> -n 2:

The asks page misses the budget on main too. Each selection there still reflects every
control's key shortcuts (scopes.js, reflectKeys) and lays out every margin row
(margin-layout.js, layoutMarginRows), so that case is marked xfail until neither
grows with the page.

The budget test reads a page without the suite's health sensors (browser.unwatched).
The sensors work on the main thread at every input. On the prose page at 512 they add
about 140 ms to a selection, 290 ms to a click and 210 ms to a keystroke. The growth test
still measures with them, which this leaves alone.

Part of #5194.

Not verified

  • The budget's margin on a CI runner: main's worst passing page (threads) took 45 ms at
    512 on this Mac at a load average of 10 to 25, against the 100 ms budget.
  • The reverted base was only measured, not run through the full growth test.

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

…rge page daily

`leaf-dev scaling` timed a click, a key, Tab and a wheel step, and never made a
selection, so the daily scaling suite couldn't see #5441's bug, where every selection
change tested each of the page reading's segments. It now also times a triple click on
the page's title, the gesture a user makes to comment on a line. The selection comes
last among the inputs, so a selection left on the page changes no other input's work.

A walk of the page for each selection grows only linearly, and the daily growth check
fails only exponents past 1.5. With #5441's runtime change reverted, the selection's
growth fits exponents of 0.97 to 1.03 and passes that check. So a selection is also held
to a budget at `REFERENCE` (512): 100 ms of main-thread time (`SELECT_BUDGET_MS`,
`scaling.over_budget`). A selection's fixed work already takes longer than the frame
root `AGENTS.md` gives a gesture's own result, so the budget is the 100 ms in which that
rule puts the server's reading on screen. `leaf-dev scaling` names a selection over it
on a run whose sizes include 512, and the new daily test
`test_a_selection_fits_its_budget_on_a_large_page` fails it on each browser page.

Select ms at 8 and 512 from `leaf-dev scaling --sizes 512 --base REF`, where REF is
main with #5441's runtime change reverted:

| Page     | #5441 reverted | main     |
| -------- | -------------- | -------- |
| document | 68 → 1,602     | 32 → 40  |
| asks     | 31 → 427       | 26 → 152 |
| prose    | 26 → 140       | 23 → 30  |
| threads  | 41 → 60        | 26 → 45  |

The asks page misses the budget on main too. Each selection there still reflects every
control's key shortcuts (`scopes.js`, `reflectKeys`) and lays out every margin row
(`margin-layout.js`, `layoutMarginRows`), so that case is marked `xfail` until neither
grows with the page.

The budget test reads a page without the suite's health sensors (`browser.unwatched`).
The sensors work on the main thread at every input. On the prose page at 512 they add
about 140 ms to a selection, 290 ms to a click and 210 ms to a keystroke.

Co-authored-by: Claude Opus 5.5 <[email protected]>
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]>
@max-sixty

Copy link
Copy Markdown
Owner Author

Superseded by #5576, which landed: leaf-dev bench replaces leaf-dev scaling, and a triple-click selection of the title is one of its inputs (--input select). It reads no budget, since no test passes or fails on a benchmark's reading any more (#5522); the daily bench job charts the selection's CPU with the other inputs.

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

@max-sixty max-sixty closed this Nov 6, 2026
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.

1 participant