Repository navigation
Measure every page and input with one leaf-dev bench, in place of scaling and bench-latency - #5576
Conversation
…ling and bench-latency Max asked for one benchmark taking variables rather than two that each serve pages from this tree and a base, drive inputs, time them and profile them. `leaf-dev bench` takes the page (a generated collection at sizes, or an example or the corpus), the inputs, the arms and what to read (`--read cpu`, `paint`, `server`), with `--profile`; scaling is the same benchmark over several sizes, with the exponent in its table. Both old commands are deleted and every caller cut over. Each input is one entry in `INPUTS`: scaling's click, key, leave, Tab, wheel and revision, bench-latency's comment, card move, agent reply, status and stamped revision, and a triple-click selection of the title, which replaces #5472. Every input runs in every pass where the page holds what it needs: the CPU pass keeps scaling's method (thread ticks, idle subtraction, means over several inputs, interleaved rounds and the lowest reading), and the paint pass keeps bench-latency's (painted.js goals, the POST's answer, request attribution against what the page starts alone, long frames, and --profile's trace). Each pass reads a page built afresh, so no input meets what another pass or round left on it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
leaf-agent
left a comment
There was a problem hiding this comment.
The branch now conflicts with main: #5567 (e99fc3aa6) edited dev/leaf_dev/commands/scaling.py, and this PR deletes that file. The edit added a rows collection (table_rows, one ask and an n-row table) to COLLECTIONS and to the browser's default AXES, so the daily job and its chart would cover the quadratic table restyle that #5567 fixed. If you resolve the modify/delete conflict by removing the file, rows disappears with nothing to flag it: bench.py's COLLECTIONS has no rows entry, and its AXES is still ("asks", "document", "prose", "threads"). When you rebase, move table_rows into bench.py and add "rows" to COLLECTIONS and AXES. The daily bench job then keeps measuring tables, under the new chart names.
…an't read The daily command crashed on the threads page at 64 sections: the reply's `leaf wait` delivery carried every seeded event, in 14 parts with no `batches`. A generated page whose log holds pending input is now delivered and acknowledged as it is built, as the session holding a page would have taken it in, so the reply reads only its own question. results.json is written after each page, so a failure keeps the pages before it. The review's other fixes: - Firefox reads cpu by default, and each refusal names only the option that caused it. - The paint pass reports the inputs a page lacks, as the CPU pass does, and `--read paint` with no painting input is refused before any page is built; `table` takes an empty set of readings. - `--read server` refuses `--base` and authored pages again, as `leaf-dev scaling --server` did. - The chart is "Bench at 64 sections" and holds only the load's and each input's CPU and each gesture's `shown`; the step's guard is 120 minutes. - One `lowest` serves the browser and the server; whether an input posts comes from its goals; the header says why each pass reads a POST its own way. Checked: the daily job's two steps at --rounds 1 and its jq; the refusals; `--read paint --input move --input click` on asks naming move missing; Firefox's default reads; reply on threads and messages at 64. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… log at build Acknowledging a seeded page's pending input as it was built changed the page the benchmark measures: it wrote a pickup per seeded comment and a receipt, which turned each seeded thread from Queued to Delivered, and read the threads page's click about 20% cheaper, while the server pass read the page unacknowledged. The page now stays as generated, and the reply's setup follows each part of its delivery (`leaf delivery read <id> --part N`), as the delivery tells an agent to, and joins their text. Checked: `leaf-dev bench threads messages --sizes 64 --input reply`, and the daily job's browser step at one round. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…TIONS and AXES #5567 added a rows page (table_rows) to scaling.py, which this branch deletes; it now lives in bench.py's COLLECTIONS and AXES, so the daily run measures tables. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ge (#5580) Sending a comment on the generated asks page at 256 sections now paints in a median 184 ms rather than 435, and entering or leaving a comment box that floats over the page no longer restyles every element on it. ## Cause While focus is in a `leaf-text` inside a box standing in a plane, such as the comment box on selected words or a margin card's reply, `floating.js` (`readFloatingEditor`) sets `data-lf-floating-editor` on the root, and `base.css` zeroes the root's scroll padding with `scroll-padding: 0 !important`. At rest the root's `scroll-padding-top` is `var(--lf-landing-top)`, a registered custom property, so the zero made the root stop reading that token, and leaving the box made it read the token again. On Leaf's pages in Chromium 156, that flip restyles every element. On the 256-section asks page (14,257 elements), with the box open, it cost 174 ms of style at each entry and each exit. A change between two literals, between two reads of the token, or to and from an unregistered `var()` cost 0.1–0.2 ms. The review narrowed the trigger to the root ceasing to read this token. On a plain 4,000-element page, no flip to or from a registered token restyled more than 4 elements. On Leaf's asks page at 64 sections, main's flip restyles 12,103 elements, and only 8 when another root property keeps reading `--lf-landing-top` or the token is a constant. The send keystroke pays it: the trace of `Control+Enter` in the comment box at 256 sections showed one forced style recalc of 47,805 elements (237 ms traced), read by `letGo` → `landingPlace` → `pageReading` → `readingBounds` → `shownWindow` (`geometry.js`), after `readFloatingEditor` removed the attribute as focus left the box (Chromium's invalidation tracking names `data-lf-floating-editor` on `HTML`). The same restyle ran when the user entered the box. It is the 255 ms of forced style and layout under `field-keys.js` `LEAF-TEXT.onkeydown` that the first full `leaf-dev bench` run of #5576 read on that page. The flip arrived with #5417, which moved the override into `base.css` as `!important` so that it wins the top edge again. Before that, the unlayered override lost the top edge and changed only the literal bottom edge, which costs nothing. ## Change The zero is now a product of the same token, `calc(0 * var(--lf-landing-top))`, so the root reads `--lf-landing-top` in both states. The computed padding in a floating editor is still `0px` on all four sides, checked in Chromium, Firefox and WebKit, and Leaf's landings still read `--lf-landing-top` directly. The rule's comment in `base.css` says what was measured and names the test that guards it. `render_harness.restyle_counts` reads the elements each style recalc restyled from Chromium's trace. The new test and `test_code_copy_reads_sources_before_positioning_many_controls` both use it in place of their own copies. ## Evidence Main against this branch on the asks page at 256 sections, the comment input of `leaf-dev bench` run by a scratch script: drag-select the first paragraph, open the box, type, then `Control+Enter`. "Painted" is `painted.js`'s message goal from the keystroke; CPU is the main thread's thread ticks over the keystroke and the 1.5 s after it, less the idle rate. Eight interleaved sends each, at load 4–5: | | painted ms, median (range) | send CPU ms, median (range) | | --- | --- | --- | | main | 435 (403–515) | 517 (494–593) | | this branch | 184 (179–281) | 270 (262–275) | In these eight sends main paid the restyle every time (CPU 494 ms or more). In the review's eight interleaved sends, main restyled the whole page in 6 of 8, painted median 421 ms (187–533), and this branch in 0 of 8, median 190 ms (184–309). At 64 sections, the lowest of three rounds read 152 ms painted on main and 95 on this branch. Firefox (review): the flip costs at most 1 ms with the box open, on main and on this branch alike. On the corpus, `uv run leaf-dev bench-latency --page corpus --transition comment --runs 3 --base HEAD` reads 173 ms painted on both arms; its comment follows bench-latency's open Threads view, where the send's focus moves to the panel's reply and the root keeps the attribute. The send still grows with the page (95 → 184 ms painted from 64 to 256 sections). Most of the rest is the margin's two layout passes per send, each over every row, and the new comment's mark adds Chromium's per-frame cost of a text-decorated custom highlight. Neither is changed here. ## Test `test_entering_and_leaving_a_floating_comment_box_restyles_only_the_chrome` (`tests/browser/test_chrome_contracts.py`) opens the box on a 600-paragraph page, then Tabs out of its field and clicks back in. It counts the elements each style recalc restyled in a trace, against a control that restyles the whole page (a custom property set on the root). With main's `base.css` both moves restyle the whole page (3,973 and 3,982 elements against the control's 3,807), so the test fails; on this branch it passes. Unthrottled, 18 `leaf-dev flake` copies failed 18 of 18 with main's `base.css`; on this branch 18 copies passed 18 of 18 at `--cpu-throttle 10` and at 20 (review). It depends on CPU speed in one direction. With main's CSS at `--cpu-throttle 10` under six concurrent copies, 2 of 18 and then 6 of 18 copies passed, so on a slow machine main's flip isn't always expensive. It never fails falsely on this branch. Ran: that test (before and after the helper), `test_code_copy_reads_sources_before_positioning_many_controls`, `test_a_compact_comment_keeps_no_room_for_send_under_a_mouse`; the floating-editor, caret-reveal and landing tests #5417 named, `-k "caret or reveal or resume or floating or foot or reply_row or follows or wheel_return or grows_back"` over `tests/browser/{drafts,margin,threads,navigation}`, `test_render_send_placement.py` and `test_chrome_contracts.py` (85 passed). Two of those fail the same way with main's `base.css`: `test_a_caret_is_drawn_at_a_lines_end_and_after_a_list_bullet[firefox_browser]` (a `wait_for_function` timeout) and `test_a_zoomed_floating_draft_and_sent_comment_fit_a_narrow_window` (a `ResizeObserver loop` window error). Pre-commit on the changed files. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…ails without it (#5589) While the user writes in a floating comment box, the root drops its scroll padding (`data-lf-floating-editor`, `browser/base.css`), because the browser's caret reveal through a box anchored to the page applies that padding and moves the words beneath a box already in view (#4821). Nothing in the suite failed with that rule removed: #4833's `test_a_card_at_the_windows_foot_grows_back_to_how_it_stood` stands its card in the window plane, which writes no `position-anchor`, so the reveal stops at the box there. This adds a test that does fail, and records why the rule has no structural replacement. - **Test.** `test_writing_in_a_comment_box_over_the_window_foot_moves_no_words` (`tests/browser/test_chrome_contracts.py`, Chromium and WebKit) opens a comment box on words low in a 1512×860 window, so the box stands over the foot band the panel states, types four letters, and asserts the page didn't scroll. It also asserts the caret stands inside that band, so a layout change that moves the box clear of it fails the test rather than passing it vacuously. With the rule's declaration removed, the words move 16 px in Chromium 156 and 14–21 px in WebKit 27.2. - **Why the rule stays.** Chromium stops a scroll-into-view at a fixed box only when the box has no anchor scroll adjustment (`IsFixedToFrame`, `scroll_into_view_util.cc`); since crbug.com/469481151 an anchored fixed box bubbles to the root and takes its padding, pinned by WPT `css-anchor-position/scroll-to-anchored-fixed-001…006`. WebKit does the same (`adjustForScrollByAnchor`, `LocalFrameView.cpp`). Firefox 157 reveals nothing through a fixed box. An agent tried, on a plain anchored contenteditable and in Leaf: the field or the box as its own scroller, `overflow`, `contain`, `overscroll-behavior`, the top layer (popover), `position: absolute`, `scroll-margin` on the caret's text, and taking typing in `beforeinput`. Each either still moved the page in Chromium or WebKit, or stopped the box following its anchor. The comments in `base.css` and `floating.js` now name WebKit and say what was rejected. - **Engine note.** `notes/browser-support.md` records a Chromium bug found on the way: each reveal of an anchored fixed box made before the next frame scrolls the full amount again (three `scrollIntoView` calls scroll 270 px where one scrolls 90; four keys in one frame 240 px where one scrolls 60). WebKit reveals once. It is the overshoot #5417 accepted, and the note gives the check that shows when Chromium fixes it. - The rule's comment now names `leaf-dev bench`, which replaced `leaf-dev scaling` in #5576. Checked: the new test passes on both engines at the head and fails on both with the rule's declaration removed (Chromium 2076 → 2092, WebKit 2075 → 2096, rerun independently); #5580's restyle test passes; pre-commit on the changed files. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…s only the row (#5623) The margin layout pass wrote each row's seat as `--lf-margin-x` and `--lf-margin-y`, which `annotation-theme.css` turned into the row's `margin-left` and `margin-top`. Those custom properties are unregistered, so they are inherited, and every row the pass moved restyled its whole subtree. The pass now writes `margin-left` and `margin-top` on the row directly. Nothing else in the tree, packages and theme included, read the two properties. Moving every row by a pixel on `leaf-dev scaling`'s asks page at 64 sections took 11.1–17.7 ms in Chromium through the custom properties and 2.2–2.9 ms through the margins (least of 11 moves, two rounds); a registered, non-inherited custom property took 6.3–7.4 ms. In Firefox it took 5 ms against 1. An agent's revision adding or removing one paragraph spent 59.5 and 67.8 ms in its margin passes at 64 sections in Chromium, against 41.0 and 42.3 with this change. These readings were taken on the base before #5576 renamed the benchmark `leaf-dev bench`. ## The write watch needs no exception The custom properties kept the seat's text exact. A style attribute prints a plain length to six significant digits, so from 10,000px down a long page a sub-pixel move can leave the attribute's text as it was. Layout reads the full length: in Chromium and Firefox a row at 1,234,567.578125px follows 1, 2 and 4px moves of its target exactly either way, and setting a margin to the length it already holds records no mutation. Only the suite's write watch (`tests/write_watch.js`), which judges a write by its text, misreads such a move as a write that changed nothing. `test_distant_margin_coordinates_follow_small_moves_without_restatement` stood its target at 1,234,567px, where the text rounds to `1.23457e+06px` and a 1px move doesn't show, so the watch failed it. The test now stands the target at 123,456px. There the text prints whole pixels, so each of the test's 1, 2 and 4px moves changes it, and the watch judges the passes over an unchanged layout as it does on every other page. At the old distance the test still fails the watch (checked). An earlier version of this branch added a margin-specific exception to the watch instead. This leaves one known false finding. An independent review moved the test's target to 12,345.578125px by 1/64, 2/64 and 4/64px: the row followed exactly, and the watch then reported an unchanged write on the row. No test in the tree places content 10,000px or more down a page apart from this one, and a watched test that does meet it fails loudly and names the row. So the watch keeps no rule for it until a test needs one, and the `margin-layout.js` header says why the watch would misread such a move. ## Checks - Ten margin browser tests by node id (rail, pins, clusters, scrollers, the distant test) pass on current main. `test_keyboard_arrival_at_a_cluster_shows_all_its_entries_for_the_keys_to_walk` fails both with and without this change, and on main's latest finished push run; it is inherited. - Before the rebase onto current main: `leaf-dev stills` over 30 margin and thread states gave byte-identical screenshots in Chromium and Firefox, and `pnpm run check` and `pnpm run test:runtime` passed. - Pre-commit passes on the changed files. > _This was written by Claude Code on behalf of max-sixty_
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 scalingandleaf-dev bench-latencywith oneleaf-dev bench,and deletes both, with every caller cut over and no alias.
COLLECTIONS, measured at each size beside theBASE page) or any example or the corpus by name.
INPUTS: scaling's click, key, leave, Tab, wheel andrevision; bench-latency's comment, card move, agent reply, agent status and stamped
revision (
stamp); and a triple-click selection of the title (select), whichreplaces Time a selection in leaf-dev scaling, and hold it to a budget on a large page daily #5472. A page without what an input needs (an option, a card) reads none of
it and the report names it missing.
arms.choose_arms, as before.cpu(scaling's CPU pass),paint(bench-latency's time to thepainted 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, therenamed
server_scaling.py), for this checkout's generated pages only, as before.Default
cpuandpaint, and in Firefoxcpu.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 inone table, a row per reading and a column per size and arm, and
results.jsonkeepseach round's readings and the table's lowest (
lowest), which the daily chart reads.Each measurement's method
Kept as it was:
idle subtraction, the mean over each input's count, per-window
readyfor inputs thatneed setup, interleaved rounds and the lowest reading.
answer by attempt, request attribution against what the page started while left
alone (starters pooled across rounds), long-frame owners, and
--profile's trace andattribution.
What changed, each a call Max may reverse:
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.
opens the views it needs. bench-latency opened the Threads view first, a habit from
the classic chrome's always-visible thread list (Remove the classic chrome: the floating panel is Leaf's only chrome #3100). An open Threads view slows
the server's reading on screen: a click's
shownon the asks page at 128 sectionsread 59–61 ms with it open and 43–47 ms folded, three fresh pages each, interleaved.
four times, a revision twice, the conversation's inputs once) and keeps the median,
as scaling read
shownover four clicks. Every round's samples are inresults.json.printed median [min-max] over runs.
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).
revisionsaves only, inserting a paragraph under the title, as an agent'sordinary save does (scaling's input inserted and then removed one). bench-latency's
revision, a save followed at once by
leaf page stamp, is thestampinput, andthe note's stamp-route analysis now runs as
leaf-dev bench corpus --read paint --input stamp --base.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-tzon the triage board, bench-latency's first move). The agent'sthread 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.
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 paintalso counts requests and bytes, from the same window, so theyhave no read of their own.
--browser firefoxreads onlycpu: the paint pass needs Chrome's DevToolsprotocol for its requests, and bench-latency ran only in Chromium.
(
leaf-dev bench --sizes 64,128,256 --rounds 2). Its chart is now "Bench at 64sections" 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 singlepaints stay in the summary, the log and the artifact.
gh-pagesholds no readingyet, so the rename loses nothing.
the first
leaf waitdelivers them all with the question, in parts (14 on thethreads 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, leavingthe seeded threads queued as the page was generated.
compare_profilesis gone: its side-by-side window and render times repeatedwhat the table and each arm's profile already print.
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 paintwith no painting input before it builds a page, and the paint pass skips aninput 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.pyandbench_latency.py.CPU, asks page, lowest of two rounds (
leaf-dev scaling asks prose --sizes 64,128 --rounds 2at load 6 againstleaf-dev bench asks prose --sizes 64,128 --rounds 2 --input click --input key --input leave --input tab --input scroll --input revisionatload 4), ms at 8 / 64 / 128 sections:
shownThe 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_passthree times on each of two pages read14.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:
shownby about 2 ms, and
leaveat 64 sections by about 3 ms. Forshown, the likely causeis a colder page: scaling clicked for
shownafter its whole CPU pass, and here thefirst 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 3againstleaf-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:
shownThe 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,256againstleaf-dev bench events options --read server --sizes 128,256): the same code, readingwithin 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 nowbench, charting the load's andeach input's CPU and each gesture's
shownat 64 sections: the readings it chartedunder new names, less the server's
eventtime and size, plus the new inputs' CPUand the comment's
shown), rootAGENTS.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 infloating.js,toc.css,test_interact_layer.py,painted.js/py,main_thread.py,profiles.pyandbrowser.py.Size and checks
bench.pyis 2,175 lines wherescaling.pyandbench_latency.pywere 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 1in 723 s at load 6–7 over asks,document, prose and threads, and
uv run leaf-dev bench --read serverin 163 s; thechart step's
jqover theirresults.jsongave 56 series (asks: load cpu468.91ms, ...). The rows page #5567 added, now in
COLLECTIONSandAXES, ran alone in168 s at load 4–5 (
leaf-dev bench rows --sizes 64,128,256 --rounds 1, exit 0) andadds 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, theCPU growth listing and the paint attribution);
--base(triage-board's move andstatus on the merge base and the head);
--browser firefox, whose default read iscpu;--read paint --input move --input clickon asks, which names move missing;the reply on threads and messages at 64; the refusals of
--read paintwith nopainting input, of
--read serverwith--baseor an authored page, of Firefox with--read paintor--profile, and of an unknown PAGE;uv run pre-commit runonevery changed file, including
ty,vultureandactionlint.Not verified: the corpus page; WebKit, which the command refuses as before.
Supersedes #5472.