Skip to content

Keep the performance budgets

The app has budgets for how fast it feels (#73): 100 ms for a click to show that it was taken, 1 s for a list to be there. All of them are in one file, scripts/perf-budgets.json (#4784).

What each pull request holds

CI's runners are shared, so a time measured there measures the load. A pull request is held only to what does not change with load:

Budget Checked by CI job
web.gzipBytes: the web page's scripts, styles and HTML, gzipped Web/test/perfBudgets.test.mjs web
web.callsBeforeFirstList: the calls the page makes from its link opening until its first list Web/test/perfBudgets.test.mjs web
host.leanAgentBytes: the largest lean Agent record in agents/list Go/internal/agentsd/perfbytes_test.go go
host.catchUpBytes: one client/catchUp answer for 50 live sessions Go/internal/agentsd/perfbytes_test.go go
SCIM at 5,000 users and 500 groups (FR-023): the store calls, reads and bytes of each request are no more than at 100 users and 10 groups TestSCIMAtSize, Go/internal/controlplane/scim_test.go go

A check that fails says the number, the budget and the file. Make the change smaller, or, when the change is worth the bytes, raise the budget in scripts/perf-budgets.json in the same pull request and say why in its body.

To run them before a push:

scripts/web.sh build && (cd Web && node --test test/perfBudgets.test.mjs)
Go/scripts/go.sh test ./internal/agentsd -run 'KeepsItsBudget'

What runs at night

The Performance budgets workflow (.agents/workflows/performance-budgets.md) runs scripts/perf-nightly.sh on this Mac at 03:00. It seeds a scratch root (41 live sessions, a transcript of 100,000 entries, a repository of 40,000 files), launches a scratch app on it, and measures against the night budgets:

  • the host's answers, with scripts/perf-budgets.py;
  • the Mac window's cold start, first list and chat open (sessions in two folders, so some opens change the folder too; the separate project switch figure was retired, #5427), with scripts/perf-window.sh, which opens the sidebar's rows through the window's walk socket (#1172), so a locked screen does not stop it (#5427);
  • the web page's first list, session open, long transcript, send to echo and Work list, second open, from the page's own performance marks (agents:first-list, agents:session-open, agents:send to agents:echo, agents:work-list-read to agents:work-list-copy: Work ▸ Issues after a reload, drawn from this device's copy, #4930; skipped when the scratch forge kept no copy), with Web/test/walk/budgets.mjs. The send goes to a session of the stand-in runtime (scripts/fake-acp-runtime.py, as grok), first on the PATH of a scratch login shell that the host is given. The run checks runtimes/list first and stops when the host's grok is another one: it never prompts a real runtime;
  • the calls the Mac window and the Remote (in the walk simulator, paired with the scratch root) make before their first list, against night.counts (#4891). The host counts them per connection and says so in its log, first list: mac after 1 calls: daemon/ping (Go/internal/agentsd/firstlist.go). Neither app has a test that runs its model against a fake host, so these are counted at night and not on each pull request. --no-remote leaves the Remote out;
  • the tests marked .perfBudget, and the Go tests in its GO_PERF_TESTS (with no -race: SCIM's 200 ms p95 at 5,000 users, #5911), with scripts/perf-tests.sh.

The report goes to ~/.agents/reviews/performance-nightly/<date>.md. When a time is over its budget, the run files an issue, "Performance budgets over at night", labelled feature:performance, or adds its numbers to the one still open.

To run it by hand, on a quiet Mac:

scripts/perf-nightly.sh --no-issue

The phone: your check

No runner has the phone on Wi-Fi or cellular, so its times stay a check by hand. About once a release, on the iPhone:

  1. Quit the Remote. Turn off Wi-Fi, so the phone is on cellular.
  2. Open the Remote and count the time until the session list is there. The budget is 2 s.
  3. Open a long session. The budget is 500 ms until its last messages are there.
  4. Turn on Wi-Fi and do steps 1 to 3 again.

When a time is over, file an issue labelled feature:performance with the times, the network and the phone.

Many machines (#5282)

scripts/scale-fixture.sh STORE_DIR [N] writes 1,000 fake machines into a scratch control plane's store, before agents-control starts on it. The fixture has no host behind a machine, so each lists as offline. The budgets are in scripts/perf-budgets.json, under scale:

  • machines/list with a limit of 50: under 50 ms at 1,000 machines. Go/internal/controlplane/scalefixture_test.go times the whole list now (a ceiling of 500 ms, measured at 95 ms under -race) and holds the time off CI (CI only logs it); the wire step that adds a limit switches it to a limit of 50 and 50 ms.
  • A web refresh makes a fixed count of calls, the same at 1 and at 1,000 machines, not a count for each machine.
  • The sidebar's Machines group shows at most 7 machine rows plus All Machines.

The last two are proved by the children of epic #5281 that change the web store and the sidebar.