Repository navigation
Ask a table first whether any row opens with a name, so a long table's style stays linear - #5567
Merged
Merged
Conversation
…s style no longer grows with the square of its rows The reading face's rules for a table whose rows open with names (`table:has(> * > tr > th[scope="row"]:first-child) > * > tr > :first-child`, with its scrolled and right-to-left variants) and for a table of captures asked the table's `:has()` again for every cell they tested. Chromium answers a `:has(> …)` by reading the table's rows afresh each time, so a table's style took time growing with the square of its rows; a plain table fails the `:has()` only after reading every row, so it paid most. Each family is now an `@scope` whose root is that `:has()`, which the browser answers once per table. The rule hiding a declared Markdown file's `pre` beside its prepainted rendering (base.css) had the same shape and takes the same form, and browser/AGENTS.md says why such a `:has()` belongs in a scope. What the rules draw is unchanged: every cell and its `::after`, in every kind of table (plain, row names with and without a head row, right to left, nested, captures, linked captures), at rest, scrolled sideways and with focus inside, computes the same styles on main and here in Chromium and Firefox, and `leaf-dev stills` shows no change in either engine on every page with a table, the corpus included, at rest and scrolled sideways. `:scope` weighs one class where the `:has()` chain weighed more; the only rules in the reading face's layer that set the same properties on a cell, `:is(th, td)` and `th:not([scope="row"])`, still weigh less. `leaf-dev scaling rows --sizes 64,512,2048 --base`, least of two rounds, ms of main-thread CPU at 2,048 rows (512 rows in brackets): - Chromium: load 8,514 -> 1,793 (815 -> 628); Tab 459 -> 173 (88 -> 58). - Firefox, linear before and after: load 401 -> 371; Tab 75 -> 73. At 8 and 64 rows the arms are within the run's noise (least of four rounds at 64: 193 -> 183 ms). `rows`, one ask and a table of n rows of four cells, joins `leaf-dev scaling`'s collections so it can measure a table's growth by name. The rest of the shipped CSS has 113 selectors with a `:has()` a combinator follows. Timed at 1,000 and 4,000 members of the group that grows, Chromium is quadratic for options.css's `lf-options:has(> lf-option > strong) > …` family (and its `:not()`), on options without a leading `<strong>`: 9 ms per restyle of the group at the largest real ask's 108 options, 117 ms at 432, against 3 and 11 in Firefox. Rewriting it reweighs some forty rules whose cascade rests on ties, so it is left for its own change. A workspace main's children and main's children before the parts measure quadratic only at sizes their layouts never reach (105 children of main at most on this Mac's pages). The rest are bounded by Leaf's own markup or gated by a compound that rejects all but one member first.
`rows`, one ask and a table of n rows, joins AXES, so `leaf-dev scaling` with no axis and tests/journeys/test_scaling.py measure a table's growth and the daily chart records it. A table's style grew with the square of its rows until the reading face scoped its table rules to the table; extrapolated from the 64, 512 and 2,048-row readings, that growth would fit past SUPERLINEAR over the suite's 64 to 256 rows, so the suite should fail its return. `test_no_cost_grows_faster_than_the_page[rows]` took 190 s here.
…scope reaches only its root's subtree A scrolled table whose rows open with names fades the columns passing under the names from the ground at the names' far side. The right-to-left override of that fade weighed less than the fade's own rule, so a right-to-left table drew its fade facing the names (`linear-gradient(to right, …)` in Chromium and Firefox, before and since the rules became a scope). The table now states the physical side its inline end stands on once, from its scroll direction, and the one fade declaration reads it, so no override has to win. test_a_scrolling_table_keeps_its_row_names_in_view checks the fade's direction in both directions; it failed for right to left on the old rule. Computed styles of every other cell and pseudo-element are unchanged in both engines. browser/AGENTS.md's paragraph on a `:has()` before a combinator now names a scope as the fix only for the compound's descendants, since a scope reaches only its root's subtree, and says what to do for its later siblings.
leaf-agent
previously approved these changes
Nov 5, 2026
…ys linear without a scope keyed by its type The table rules' `@scope (table:has(…))` roots named a type alone, which test_an_untyped_has_leads_only_to_a_typed_subject refuses, and base.css's `@scope (:has(…))` named no element. Each table rule is again a `:has()` on the table, now led by one whose argument starts with a descendant combinator, `table:has(th[scope="row"]:first-child)`, which Chromium keeps for the restyle, so a table without names or captures fails once rather than reading every row for each cell. The exact `:has(> * > tr > …)` follows, so a table nested in a cell is still read for itself, and the rules hold the same elements as on main. base.css's prepaint rule returns to main's form, which the test names as one that keeps a write's restyle near it; it was quadratic only in `pre` siblings, five at most on this Mac's pages. browser/AGENTS.md gives the prefilter as the fix and a scope only with a keyed root.
leaf-agent
approved these changes
Nov 5, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
Since this description becomes main's commit message: its last bullet names test_scaling.py[rows] as a daily test, but #5563 replaced tests/journeys/test_scaling.py with the scaling job in ci.yaml, which records readings and fails on none of them. rows now feeds that job's report and chart. It gates nothing.
max-sixty
added a commit
that referenced
this pull request
Nov 6, 2026
…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]>
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A growth survey of every collection found that in Chromium a table's load and Tab grew with the square of its rows (exponents 2.0 and 1.7), from the reading face's row-name rules:
table:has(> * > tr > th[scope="row"]:first-child) > * > tr > :first-childand its siblings. For a:has(> …) > …match Chromium re-checks the table's rows for each cell it styles. The largest real page here has a 319-row table.--lf-more-fade-start) and the table-of-captures rule now lead with a cheaper:has()before the exact one:table:has(th[scope="row"]:first-child):has(> * > tr > th[scope="row"]:first-child) > …. Chromium keeps the first:has()'s answer through the restyle, so a table without row names fails once instead of once per cell; the exact second:has()keeps a nested table's names to itself. A comment beside the rules says the linearity rests on that.@scope (table:has(…))form was linear too, but CI'stest_an_untyped_has_leads_only_to_a_typed_subjectrefused it, rightly: a scope root keyed by a type makes Chromium restyle the whole page when a node is added inside any table. Restyled-element counts for a node added inside a table, a row appended, cell text changed and a node added to the chrome now match main exactly, on a 64-table page and on the 512-section asks page.test_a_scrolling_table_keeps_its_row_names_in_viewnow asserts the direction.browser/AGENTS.mdsays what to do with this:has()shape.leaf-dev scalinggains arowspage inCOLLECTIONSandAXES, so the daily scaling test and its chart cover tables;test_scaling.py[rows]takes about 190 s.At 2,048 rows, least of two interleaved rounds against main at 7d2a68e: Chromium load 5,387 → 866 ms, Tab 380 → 101, an agent's revision 1,570 → 457; Firefox, linear before, 454 → 439. At 8 and 64 rows the arms are within noise.
Still quadratic: a table whose own rows have no names but which holds a named table in a cell, since Chromium doesn't cache the exact child-path check: 135 ms at 2,000 outer rows, against 1,096 on main. A sweep of the other 113 shipped selectors with a
:has()before a combinator, timed at 1,000 and 4,000 members, found one more quadratic family in Chromium, about 40 rules inoptions.cssof the formlf-options:has(> lf-option > strong) > …(9 ms per restyle at the largest real ask's 108 options, 117 ms at 432); rewriting them shifts specificity in a cascade that depends on ties, so it is left for its own change.Checks: all 175 tests in
test_interact_layer.py; 9 row-header and scroll-cue browser tests by node id; computed styles of every cell and its::afteridentical to main on seven kinds of table in both engines (right-to-left now differs as intended);leaf-dev stillsover 23 table states with no pixel changes; pre-commit. Three rounds of independent review; the first found the right-to-left fade and a wrong line in the guidance, and the third the nested-table case above.