Skip to content

Bench #4781's tabs of large documents, with the inputs that found its costs - #6033

Merged
max-sixty merged 3 commits into
mainfrom
grind/bench-documents
Nov 15, 2026
Merged

max-sixty merged 3 commits into
mainfrom
grind/bench-documents

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

leaf-dev bench now generates #4781's page, a side list of tabs each holding a large text document bound to its own source, and measures the inputs that found this week's costs on it by hand. The daily bench job runs it, so Tend's review sees these costs grow with the page.

The page

documents holds the shown document, one more in a closed tab for each eight of n, and one more again: 3 documents on the BASE page, so reveal has two closed tabs to open there, then 10, 18 and 34 at the daily sizes 64, 128 and 256, about #4781's 30 tabs at the largest. Each source is 2,048 lines of Python (16 of a listing's 128-row runs), the same at every size. So a cost that grows with the documents a page holds grows with n and shows in the exponent. A cost that grows with the length of the one document opened stays level and shows only beside another arm (--base).

The largest page holds 69,000 rows where #4781's held 2.9 million. That is enough for a walk of every panel on each tab switch (#5996) to fit an exponent in Chromium, and it keeps the daily run short (below). The text is Python rather than #4781's Markdown, because Python's syntax colour paints most words, and the colour a closed tab keeps is what browse reads.

The sources are set through the fixture's data companion (page.data.json, which prepare_page sets with leaf data set), so each arm builds the page with its own Leaf. Collection gains data for it, which server_paths.build also sets in process.

The inputs

Input What it does Fix it watches
data the agent's leaf data set changes the first line of the shown document's source; painted is the frame that draws the new line #5992
reveal a click opens the second tab, then the third, neither opened before #5996
search the first /, which opens page search #5999
matches type value, which every line holds, into page search, until the count is final none yet
browse put away page search, open every closed tab, then turn the wheel a run's height down and up the last one's listing, 16 steps closed tabs keep their colour ranges (still on main; #6035)

They run in that order, so search and matches read the page before browse has opened every tab, whose kept colour every later input would meet. They need the page's own ids (#docs #d0[source]) and find the other tabs and documents by them. Each finds what it acts on through page.evaluate, never a locator, since a Playwright locator walks every element of the page for each query. holds, which decides whether a page has what an input needs, now asks the document with querySelector for the same reason. painted.js gains three facts: shows (an element is drawn and holds some words), searching (page search's field holds the caret) and searched (its count is final). BenchPage.written takes the file a command writes, here the source's file rather than the log.

What the marks hold

held now covers the requests and bytes any input causes, the size of the answer to each of its POSTs (<input> event KB) included, besides the CPU of an input the browser answers alone: root AGENTS.md, "Responsiveness", holds an input's work to what it changes. Without it, #5992's cost, every source sent to the tab after a write to one, fits exponent 1.08 with no mark, since an agent's write may grow with the page. An input whose result is the whole page is exempt, through a new Input.whole: revision and stamp, which carry the new document, and matches. A held count's noise floor is a quarter of its own reading on the BASE page and at least one, where every count's was a fixed 10 KB or one request.

Re-judged under main's rules and this branch's, the nine daily reports of 11-06 to 11-14 differ in one reading: asks comment event KB, 4.9, 8.1, 11.9 and 19.6 KB across the sizes in the six reports of 11-06 to 11-11, now marked at 1.08. Those reports showed it with no mark; it reads level from 11-12 on. On this page's runs the only differences are matches, which whole lets grow, and data KB with #5992 reverted.

Evidence

All on this Mac (M5 Max, 18 cores, load average 3–21 from other sessions), uv run leaf-dev bench documents --sizes 64,128,256 ….

Current main, Chromium, the daily job's command (--rounds 2 --input data --input reveal --input search --input matches --input browse), 266 s:

                            8         64        128        256   exponent
elements               6435.0    20988.0    37620.0    70884.0         - 
load cpu ms             200.0      242.8      299.5      510.5      1.43 
data cpu ms              23.1       21.3       25.5       30.7         - 
reveal cpu ms            46.0       42.0       43.9       47.1         - 
search cpu ms            18.3       17.3       18.4       19.7         - 
matches cpu ms          290.5      718.7     1271.1     2328.5      1.13 
browse cpu ms            15.4       19.5       25.4       28.0      0.81!
data painted ms         133.5       99.9       68.6       99.5         - 
data requests             1.0        1.0        1.0        1.0         - 
data KB                  82.6       82.6       82.6       82.6         - 
reveal painted ms        37.2       33.5       34.8       36.1         - 
reveal requests           0.0        0.0        0.0        0.0         - 
reveal KB                 0.0        0.0        0.0        0.0         - 

Current main, Firefox, the first commit's page and input order with --browser firefox:

                         8         64        128        256   exponent
elements            4351.0    18904.0    35536.0    68800.0         - 
load cpu ms          344.8      521.9      557.5      917.8      0.85 
data cpu ms           40.6       56.2       43.4       52.0         - 
reveal cpu ms         73.5       78.3       65.0       71.7         - 
browse cpu ms         43.9       51.4       54.6       68.1         - 
search cpu ms         37.5       61.3       40.8       48.5     -0.56 
matches cpu ms        98.3      115.0      201.3      287.1      0.87 

What main shows, with a V8 profile of each growing input from --profile, which lists the functions whose time grew past the input's limit from the smallest page to the largest:

  • browse, 0.81 ! in Chromium, and 0.96 and 1.04 in two runs of browse alone. A closed tab keeps the colour ranges of the runs it last showed (896 a tab here), and each run a step colours rebuilds highlights holding every opened tab's ranges. The profile names unpaint and follow (lf-text-document.js), 3 to 40–45 ms. This is the cost Open a closed tab without walking every panel's document #5996's body left unmeasured, which Colour only the documents on screen, and rewrite only the rows a new text changes #6035 removes: with its change, review read browse level. Firefox grows too (44 to 68 ms), but under the noise floor in one of two runs.
  • load cpu, 1.43 here and between 1.02 and 1.71 across seven runs on main, above 1.5 in two. The profile names an anonymous function at addressable-names.js:187, headingsIn's query of every heading under an element, growing from 1 to 126 ms (exponent 1.54). Read from the code, not confirmed: each document's first draw may start a new page reading, whose heading queries walk the whole page again.
  • matches grows at 1.13 in Chromium and 0.87 in Firefox, within its limit as a whole input. Chromium's 2.3 s at 34 documents against Firefox's 0.29 s is Open page search without restyling the whole page #5999's note that a match's visibility read styles each run it lies in.
  • search, data and reveal stay level in both engines. In the first commit search ran after browse and grew with the tabs browse left coloured (0.79 !); run before it, it reads 17 to 20 ms.

Each fix reverted in the working tree (git revert --no-commit), with --base HEAD for main beside it. The #5992 and #5999 rows are from the first commit's page, which held one document fewer:

CI time

The daily job measures documents in a step of its own after the default pages, with only these five inputs, since the document page's text already grows under every other input. The step runs after a failed one, and the readings to chart are collected once both have run, so one page's failure keeps the other's chart. Its table goes to documents.txt in the bench-report artifact, which Tend's benchmark review (.claude/skills/running-tend/SKILL.md) now names beside the browser and server tables. The command took 266–284 s here. To scale it to the runner: the rows page with the daily job's arguments took 397 s here and 7.5 minutes on the runner on 2026-11-14, a ratio of 1.13, while the runner's load CPU is 2.2 times this Mac's. So the job should grow by between about 5 and 10.5 minutes, nearer the first, since most of a run is waiting rather than CPU.

Not verified

  • The runner's time for the new step, which the first daily run's step timings will show.
  • Firefox on CI. The Firefox clock (ContentClock) reads macOS's thread times, so the daily job reads Chromium only, and a Firefox-only cost such as Open page search without restyling the whole page #5999's shows only in a local run.
  • WebKit.

No dev/tests smoke test: the bench has none, and each input ran here in both engines at four sizes.

Calls Max may reverse

  • held covering requests and bytes, with Input.whole to exempt a revision and a search.
  • The CI step's input list, rather than every input on this page.
  • Python content, 2,048 lines a document and 2 + n/8 documents.
  • browse's 16 steps, which over two runs fitted 0.96 and 1.04 where three runs of 8 fitted 0.49 to 0.75.

Part of #5194.

… costs

`leaf-dev bench documents` generates a side list of tabs, each holding a
text document bound to its own source: the shown document and one more in
a closed tab for each eight of `n` (33 at 256, about #4781's 30), each
2,048 lines of Python. The documents grow in number and each stays as
long, so a cost that grows with the documents a page holds shows in the
exponent. The sources go through the fixture's data companion, so each arm
builds the page with its own Leaf; `Collection` gains `data` for it.

Five inputs read the costs agents found on #4781's page by hand this week:
`data` (an agent's `leaf data set` changing one line of the shown
source, #5992), `reveal` (opening a closed tab, #5996), `browse` (a run's
height of wheel after opening every tab, for the colour ranges closed tabs
keep), `search` (the first open of page search, #5999) and `matches` (a
search for a word on every line, to its final count). Each finds what it
acts on through `page.evaluate`, as `holds` now does, since a Playwright
locator walks every element of a large page for each query.

`held` now covers the requests and bytes an input causes, so a write to
one source that sends every source is marked; `Input.whole` exempts a
revision, which carries the new document, and a search's count. On the
daily report of 2026-11-14 only `revision KB` and `stamp KB` grow, so the
existing pages gain no mark.

Each fix reverted shows its cost again, against main beside it: #5992's
`data KB` fits 1.08 `!` (164 to 2,722 KB; main 82.6 at every size),
#5996's `reveal cpu` 1.77 `!` in Chromium (43 to 118 ms; main 41 to 53),
#5999's `search cpu` 0.82 `!` in Firefox (45 to 165 ms; main 24 to 30).
Main itself marks `browse` (1.21, `unpaint` growing), `search` in
Chromium (0.79) and `load cpu` (1.53, `headingsIn` growing).

The daily job runs the page with these five inputs: 284 s on this Mac.
…answer

Review of the documents page found that `search`'s Chromium mark was
`browse`'s cost seen again: run alone, the first open of page search reads
level, and after `browse` has opened every tab, each keeping its colour
ranges, it grew 21 to 44-47 ms. `search` and `matches` now come before
`browse`, which puts away page search before it opens the tabs. `browse`
takes 16 steps rather than 8: on the page with one more document, three
runs of eight read its exponent at 0.49 to 0.75, and two of sixteen at 1.04
and 0.96.

`held` read the input of `comment event KB` as `comment event`, which no
input is, so the size of each POST's answer was judged at the loose limit,
and the fixed 10 KB floor hid a small answer's growth. A reading now names
its input by its first word, and a held count's floor is a share of its own
BASE reading, at least one. Re-judged, the nine daily reports of 11-06 to
11-14 gain one mark: `asks` `comment event KB`, 4.9 to 19.6 KB in the
reports of 11-06 to 11-11, exponent 1.08.

`reveal` opened the second tab and then the first, which the page drew at
load, so its mean halved a first open's cost. The page now holds one more
document, and `reveal` opens the second tab and then the third. The inputs
need the page's own ids (`#docs #d0[source]`) and count its tabs by them.

The daily job measures `documents` in a step of its own, which runs after a
failed one, and collects every page's readings to chart once both have run.
…ents table

`held` unpacked a reading into its first and last words, which a one-word
reading such as `elements` can't fill, so a caller passing one raised
`ValueError` where it used to get False. It now takes the first and last
word of any reading, so `elements` names no input and is not held.

The daily job writes the `documents` table to its own `documents.txt` in
the `bench-report` artifact, so Tend's benchmark review in
`running-tend/SKILL.md` now names it beside the browser and server tables.
@max-sixty
max-sixty marked this pull request as ready for review November 15, 2026 10:23
@max-sixty
max-sixty merged commit f20c08b into main Nov 15, 2026
6 checks passed
@max-sixty
max-sixty deleted the grind/bench-documents branch November 15, 2026 10:38
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