Public: anyone can read this; the crew can change it.

Count the 20-file pull page's work instead of timing it, so pull-budget stops… #17263

Closed opened this

Picked up by scout; no pull came of it (ok) · 2 runs · run

opened this

Count the 20-file pull page's work instead of timing it, so pull-budget stops failing on loaded runners

test/pull-budget.test.ts "the pull page answers warm in under 12.5 ms (20 files, 5 reviews, 3 checks)" is red in the full suite (#17245, red again when rerun alone with 7 checks on the runner) and on pull checks for #17252, #17237 and #17177, and it was blamed on #17220, which does not touch the page. Nothing covers it (triage on #17245).

Cause. It judges Server-Timing app;dur, a wall clock: the fastest of 30 holds only if one sample runs on an idle runner. test/helpers/work.ts (#7824) already says wall-clock is never judged in a pull.

What the clock stood in for (its own comment): work the page does on every warm request, "a git spawn or a lost cache". Both are countable. Statements are already pinned at 111 by the file's second test. Git spawns are counted by gitSpawns in test/helpers/work.ts, which pageWork already uses. The page's time stays judged by test/page-budget.test.ts, on CPU scaled for load, against the same budget.medianMs.

Fix (test only). In test/pull-budget.test.ts:

// drop: import { budget } from "../src/perf/page_budgets/pull.ts";  (and BUDGET_MS, RUNS)
import { gitSpawns } from "./helpers/work.ts";

/**
 * Warm requests the git count reads. The fewest is judged, so a spawn from outside the page (a
 * worker's tick, another file's tail in this process) cannot fail it, while one the page makes on
 * every request is in all of them.
 */
const COUNTED = 5;

// What the fastest of 30 stood in for, counted (test/helpers/work.ts, #7824): work the page does
// on every warm request, a git spawn or a lost cache (the head's wall and log, `keptRead`), shows
// in the git count here and in the statement count below. The page's time is judged on CPU, scaled
// for load, by test/page-budget.test.ts against src/perf/page_budgets/pull.ts.
test("the pull page spawns no git warm (20 files, 5 reviews, 3 checks)", async () => {
  await appPhase();
  const spawns: number[] = [];
  for (let i = 0; i < COUNTED; i++) spawns.push(await gitSpawns(async () => { await appPhase(); }));
  expect(Math.min(...spawns)).toBe(0);
});

Update the file's header comment (it counts the page's git and statements now, not its server time) and, in src/perf/page_budgets/pull.ts, replace "the bound test/pull-budget.test.ts also reads, so one budget holds this page" with "test/pull-budget.test.ts counts the 20-file pull's work instead of timing it".

Pin, don't bound. Expect 0. If the page spawns git on every warm request today, pin that exact number, as STATEMENTS is pinned, and name the subcommand (gitRecord.patterns() gives git <sub>). Do not raise 12.5 ms, add a ceiling, a retry or a longer timeout.

Show it in the pull.

  1. Before: on main, run bun test ./test/page-budget.test.ts in 7 shells at once, then bun test ./test/pull-budget.test.ts --rerun-each 10: red on the timed test.
  2. After, same load: green.
  3. The count is live: make the pull page skip the head's kept read (keptRead) for one run and the new test goes red; restore it.

Done when: the file is green under that load, the gate and tsc are clean, and the next full suite has no pull-budget red.

3 earlier comments
commented

#17266 already does this (test only, same file, same comment change in page_budgets/pull.ts). @scout: don't open a second pull for this issue; let #17266 carry it. One gap is noted on #17266: it judges a single warm request, and gitSpawns counts git process-wide, so a spawn from outside the page (a worker tick in the same process) can fail it. Take the fewest of 5 as the issue's code does. This issue closes when #17266 lands.

commented

Parked by the crew: the run ended without a pull: declined: #17266 already makes this change (the test, plus the same comment change in page_budgets/pull.ts), and @trevato asked on issue #17263 that no second pull be opened for it. I've pushed nothing from t

commented

Done on main already, waiting for you to close it: 73c1fa592bed5faedaace47cdb97b4951d2a39bf

commented

Closed: already done on main in 73c1fa5. Closed by the crew's live triage; reopen it to undo, and it stays open.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs