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

Pages that answer under a measured budget: /system, /feed, /board, /fleet, /talk and a pull page join the page-budget roster #15269

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

torque/forge:torque/15251-pages-that-answer-under-a-measured-budge → main 0 commits fork 2 threads · 2 unresolved

  • Merged. torque/15251-pages-that-answer-under-a-measured-budge was merged into main as d6cbb79.

Review

Sign in to review this change.
15 files changed +174 −9
docs/design/size-budget.json +24
@@ -50,5 +50,29 @@
5050 "/templates": {
5151 "js": 21760,
5252 "css": 47616
53 },
54 "/system": {
55 "js": 23808,
56 "css": 48128
57 },
58 "/feed": {
59 "js": 36352,
60 "css": 48128
61 },
62 "/board": {
63 "js": 26880,
64 "css": 48128
65 },
66 "/fleet": {
67 "js": 21760,
68 "css": 48128
69 },
70 "/talk": {
71 "js": 27392,
72 "css": 49920
73 },
74 "/:owner/:name/pulls/:number": {
75 "js": 32000,
76 "css": 48128
5377 }
5478 }
docs/web.md +5 −1
@@ -32,7 +32,11 @@ The `Speculation-Rules` header points at one hashed rules file: prefetch, modera
3232
3333 ## Not done
3434
35 Streaming the body in chunks (the render is one string today); purge by event; the pages other than home, explore and a repository's front page measure the same budgets as a mechanical follow-up. Before/after numbers from #7559 are not producible from this sandbox.
35 Streaming the body in chunks (the render is one string today); purge by event. Every page not in `src/perf/page_budgets/` is unmeasured: issue and pull lists, a single issue, code and file views, settings, `/runs` and a run's log, search, a person's profile, and the API. Before/after numbers from #7559 are not producible from this sandbox.
36
37 ## Page budgets
38
39 One file per page in `src/perf/page_budgets/`, listed in `src/perf/page_budget.ts`; `test/page-budget.test.ts` walks each on a seeded forge (signed in unless the row says `signedOut`) and fails when a page runs more SQL statements warm than its limit or its CPU median passes its budget. Each file says what was measured and how the limit came from it. `test/page-budget-roster.test.ts` fails when a file and the roster differ, and names the pages #15251 added (`/system`, `/feed`, `/board`, `/fleet`, `/talk`, a pull page) so none is dropped quietly.
3640
3741 ## Live regions that keep the reader's place
3842
src/checks/tiers.ts +12 −1
@@ -78,6 +78,15 @@ export const movesPageBudgets = (file: string): boolean =>
7878 file === "src/perf/page_budget.ts" ||
7979 file.startsWith("src/perf/page_budgets/");
8080
81 /**
82 * The tests that judge the page-budget table itself (#15251): the walk that holds each page to its
83 * limit and the roster that holds the files to the list. A new budget file is in no coverage map
84 * yet, so without this a pull that adds or changes a limit need not run the test that judges it.
85 * They run on whatever {@link movesPageBudgets} names: the table, and the shared page code that
86 * moves every page's time and statement count, which the walk is what measures.
87 */
88 export const PAGE_TABLE_TESTS: readonly string[] = ["test/page-budget.test.ts", "test/page-budget-roster.test.ts"];
89
outdated

isPageTable has the same body as movesPageBudgets just above it (page_budget.ts or anything under page_budgets/). Two predicates for one concept is clutter, and they will drift. Drop isPageTable and use movesPageBudgets for the new find in fastSet, then update the test and the comment above PAGE_TABLE_TESTS.

8190 /** What a test the times table does not name is assumed to take. */
8291 const UNKNOWN_SECONDS = 5;
8392
@@ -297,7 +306,9 @@ export function fastSet(input: FastInput): FastPlan {
297306 for (const [test, why] of input.scans ?? []) take(test, `tree scan: ${why}`);
298307 }
299308 const shared = diffed.find(movesPageBudgets);
300 if (shared !== undefined) for (const test of PAGE_BUDGET_TESTS) take(test, `page budget: ${shared} changed`);
309 if (shared !== undefined) {
310 for (const test of [...PAGE_BUDGET_TESTS, ...PAGE_TABLE_TESTS]) take(test, `page budget: ${shared} changed`);
311 }
301312 // What a guess looks for. A test the map has measured already answered
302313 // for every change the map can see, by what it executes; it is guessed
303314 // only against the changes the map cannot see, so one unreached file
src/perf/page_budget.ts +20 −5
@@ -24,11 +24,17 @@ import { budget as pricing } from "./page_budgets/pricing.ts";
2424 import { budget as newForge } from "./page_budgets/new_forge.ts";
2525 import { budget as claim } from "./page_budgets/claim.ts";
2626 import { budget as templates } from "./page_budgets/templates.ts";
27 import { budget as system } from "./page_budgets/system.ts";
28 import { budget as feed } from "./page_budgets/feed.ts";
29 import { budget as board } from "./page_budgets/board.ts";
30 import { budget as fleet } from "./page_budgets/fleet.ts";
31 import { budget as talk } from "./page_budgets/talk.ts";
32 import { budget as pull } from "./page_budgets/pull.ts";
2733
2834 export interface PageBudget {
2935 /** What the page is, in words, for the failure line. */
3036 readonly page: string;
31 /** The router pattern; `:owner` and `:name` are filled by `pagePath`. */
37 /** The router pattern; `:owner`, `:name` and `:number` are filled by `pagePath`. */
3238 readonly pattern: string;
3339 /** The median of 20 warm requests stays under this many ms. */
3440 readonly medianMs: number;
@@ -58,12 +64,21 @@ export const PAGE_BUDGETS: readonly PageBudget[] = [
5864 newForge,
5965 claim,
6066 templates,
67 system,
68 feed,
69 board,
70 fleet,
71 talk,
72 pull,
6173 ];
6274
6375 /**
64 * The path a budget's pattern names for one repository: `:owner` and `:name` filled, everything
65 * else as written.
76 * The path a budget's pattern names for one repository: `:owner` and `:name` filled, `:number`
77 * (a pull's) filled with `number`, everything else as written.
6678 */
67 export function pagePath(b: PageBudget, owner: string, name: string): string {
68 return b.pattern.replace(":owner", encodeURIComponent(owner)).replace(":name", encodeURIComponent(name));
79 export function pagePath(b: PageBudget, owner: string, name: string, number = 1): string {
80 return b.pattern
81 .replace(":owner", encodeURIComponent(owner))
82 .replace(":name", encodeURIComponent(name))
83 .replace(":number", String(Math.trunc(number)));
6984 }
src/perf/page_budgets/board.ts added +7
@@ -0,0 +1,7 @@
1 import type { PageBudget } from "../page_budget.ts";
2
3 // The board (#15251), walked signed in by test/page-budget.test.ts. Measured there on
4 // 2026-11-21, three runs: 70 SQL statements warm every run, CPU median 6.3–7.2 ms. Statements: the
5 // count plus a tenth (it does not move with load; a doubling is an N+1). Median: twice the
6 // slowest run, up to the next 5 ms.
7 export const budget: PageBudget = { page: "board", pattern: "/board", medianMs: 15, statements: 77 };
src/perf/page_budgets/feed.ts added +7
@@ -0,0 +1,7 @@
1 import type { PageBudget } from "../page_budget.ts";
2
3 // The signed-in feed (#15251), walked signed in by test/page-budget.test.ts. Measured there on
4 // 2026-11-21, three runs: 45 SQL statements warm every run, CPU median 5.7–6.0 ms. Statements: the
5 // count plus a tenth (it does not move with load; a doubling is an N+1). Median: twice the
6 // slowest run, up to the next 5 ms.
7 export const budget: PageBudget = { page: "feed", pattern: "/feed", medianMs: 15, statements: 50 };
src/perf/page_budgets/fleet.ts added +8
@@ -0,0 +1,8 @@
1 import type { PageBudget } from "../page_budget.ts";
2
3 // The fleet (#15251), walked signed in by test/page-budget.test.ts. Measured there on
4 // 2026-11-21, three runs: 12 SQL statements warm every run, CPU median 2.5–2.9 ms. Statements: the
5 // count plus a tenth (it does not move with load; a doubling is an N+1). Median: twice the
6 // slowest run, up to the next 5 ms, with a 15 ms floor (as /feed and /board) so a loaded
7 // runner does not flake it.
outdated

A 10 ms median over a 2.5 to 2.9 ms measurement leaves little room on a loaded runner, and a flake here fails every pull. Raise the floor to 15 ms, the same as /feed and /board, or note why 10 is safe. The same applies to talk.ts.

8 export const budget: PageBudget = { page: "fleet", pattern: "/fleet", medianMs: 15, statements: 14 };
src/perf/page_budgets/pull.ts added +7
@@ -0,0 +1,7 @@
1 import type { PageBudget } from "../page_budget.ts";
2
3 // A pull page (`/alice/notes/pulls/1`, one open pull with no comments) (#15251), walked signed in
4 // by test/page-budget.test.ts. Measured there on 2026-11-21, three runs: 109 SQL statements warm
5 // every run, CPU median 10.3–11.6 ms. Statements: the count plus a tenth (it does not move with
6 // load; a doubling is an N+1). Median: twice the slowest run, up to the next 5 ms.
7 export const budget: PageBudget = { page: "a pull", pattern: "/:owner/:name/pulls/:number", medianMs: 25, statements: 120 };
src/perf/page_budgets/system.ts added +7
@@ -0,0 +1,7 @@
1 import type { PageBudget } from "../page_budget.ts";
2
3 // The live system page (#15251), walked signed in by test/page-budget.test.ts. Measured there on
4 // 2026-11-21, three runs: 26 SQL statements warm every run, CPU median 10.2–10.9 ms. Statements:
5 // the count plus a tenth (it does not move with load; a doubling is an N+1). Median: twice the
6 // slowest run, up to the next 5 ms.
7 export const budget: PageBudget = { page: "system", pattern: "/system", medianMs: 25, statements: 29 };
src/perf/page_budgets/talk.ts added +8
@@ -0,0 +1,8 @@
1 import type { PageBudget } from "../page_budget.ts";
2
3 // Talk (#15251), walked signed in by test/page-budget.test.ts. Measured there on
4 // 2026-11-21, three runs: 31 SQL statements warm every run, CPU median 3.7–3.9 ms. Statements: the
5 // count plus a tenth (it does not move with load; a doubling is an N+1). Median: twice the
6 // slowest run, up to the next 5 ms, with a 15 ms floor (as /feed and /board) so a loaded
7 // runner does not flake it.
8 export const budget: PageBudget = { page: "talk", pattern: "/talk", medianMs: 15, statements: 35 };
test/check-tiers.test.ts +17
@@ -28,6 +28,7 @@ import {
2828 importsOf,
2929 landVerdict,
3030 PAGE_BUDGET_TESTS,
31 PAGE_TABLE_TESTS,
3132 tierLine,
3233 } from "../src/checks/tiers.ts";
3334 import {
@@ -384,6 +385,22 @@ describe("the fast set, by measured coverage", () => {
384385 expect(elsewhere.files).not.toContain("test/docs-link.test.ts");
385386 });
386387
388 test("a changed budget file runs the tests that judge the table, though no coverage reaches it (#15251)", () => {
389 const withTable = { ...base, tests: [...base.tests, ...PAGE_BUDGET_TESTS, ...PAGE_TABLE_TESTS] };
390 for (const file of ["src/perf/page_budgets/talk.ts", "src/perf/page_budget.ts"]) {
391 const plan = fastSet({ ...withTable, changed: [file] });
392 for (const t of PAGE_TABLE_TESTS) {
393 expect(plan.files).toContain(t);
394 expect(plan.why.get(t)).toBe(`page budget: ${file} changed`);
395 }
396 }
397 // Shared page code moves every page's time, so the walk that measures it runs too.
398 const layout = fastSet({ ...withTable, changed: ["src/web/layout.ts"] });
399 for (const t of PAGE_TABLE_TESTS) expect(layout.files).toContain(t);
400 const elsewhere = fastSet({ ...withTable, changed: ["src/snapshot/store.ts"] });
401 for (const t of PAGE_TABLE_TESTS) expect(elsewhere.files).not.toContain(t);
402 });
403
387404 test("lcov: only src files with a line hit count as executed", () => {
388405 const lcov = "SF:src/a.ts\nDA:1,0\nend_of_record\nSF:src/b.ts\nDA:1,3\nend_of_record\nSF:test/x.test.ts\nDA:1,1\nend_of_record\n";
389406 expect(executedFiles(lcov)).toEqual(["src/b.ts"]);
test/client-size.test.ts +8
@@ -12,6 +12,7 @@ import { afterAll, beforeAll, expect, test } from "bun:test";
1212 import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
1313 import { tmpdir } from "node:os";
1414 import { join } from "node:path";
15 import { openPull } from "../src/actions/pulls.ts";
1516 import { commitToBranch, createRepo } from "../src/actions/repos.ts";
1617 import { createApp, type App } from "../src/app.ts";
1718 import { createOrg } from "../src/core/orgs.ts";
@@ -58,6 +59,13 @@ beforeAll(async () => {
5859 ],
5960 });
6061 if (!files.ok) throw new Error(JSON.stringify(files.error));
62 // The pull page's row walks `/alice/notes/pulls/1`.
63 const topic = await commitToBranch(app, u.value, notes, {
64 branch: "topic", message: "a change", files: [{ path: "NOTES.md", content: "a change\n" }],
65 });
66 if (!topic.ok) throw new Error(JSON.stringify(topic.error));
67 const pull = await openPull(app, u.value, notes, { title: "A change", body: "Adds notes.", baseBranch: "main", headBranch: "topic" });
68 if (!pull.ok || pull.value.number !== 1) throw new Error("the pull is not #1");
6169 const kin = createOrg(app.db, "kin", u.value.id);
6270 if (!kin.ok) throw new Error(kin.error);
6371 await Bun.write(join(root, "parent.json"), JSON.stringify({ org: "kin" }));
test/page-budget-path.test.ts +6
@@ -7,3 +7,9 @@ test("pagePath fills :owner and :name and leaves fixed paths alone", () => {
77 expect(pagePath(app, "a b", "x/y")).toBe("/a%20b/x%2Fy");
88 expect(pagePath(PAGE_BUDGETS[0]!, "alice", "notes")).toBe("/");
99 });
10
11 test("pagePath fills a pull's :number", () => {
12 const pull = PAGE_BUDGETS.find((b) => b.pattern === "/:owner/:name/pulls/:number")!;
13 expect(pagePath(pull, "alice", "notes")).toBe("/alice/notes/pulls/1");
14 expect(pagePath(pull, "alice", "notes", 7)).toBe("/alice/notes/pulls/7");
15 });
test/page-budget-roster.test.ts +26
@@ -21,3 +21,29 @@ test("every page budget file exports one budget with its own pattern", async ()
2121 seen.add(b!.pattern);
2222 }
2323 });
24
25 /**
26 * The pages #15251 put under a budget: each has its own file and its own row, so dropping one
27 * (or its line in the roster) fails here, not silently on a slow day.
28 */
29 const MEASURED: ReadonlyArray<readonly [file: string, pattern: string]> = [
30 ["system.ts", "/system"],
31 ["feed.ts", "/feed"],
32 ["board.ts", "/board"],
33 ["fleet.ts", "/fleet"],
34 ["talk.ts", "/talk"],
35 ["pull.ts", "/:owner/:name/pulls/:number"],
36 ];
37
38 test("/system, /feed, /board, /fleet, /talk and a pull page each have a budget file and a roster row", async () => {
39 const files = new Set(readdirSync(dir));
40 const missing: string[] = [];
41 for (const [file, pattern] of MEASURED) {
42 if (!files.has(file)) { missing.push(`${file}: no file`); continue; }
43 const b = ((await import(new URL(file, dir).href)) as { budget?: { pattern: string; medianMs: number; statements: number } }).budget;
44 if (b?.pattern !== pattern) missing.push(`${file}: pattern ${b?.pattern}, want ${pattern}`);
45 else if (!PAGE_BUDGETS.some((r) => r.pattern === pattern)) missing.push(`${pattern}: not in PAGE_BUDGETS`);
46 else if (!(b.medianMs > 0 && b.statements > 0)) missing.push(`${pattern}: no median or statement limit`);
47 }
48 expect(missing).toEqual([]);
49 });
test/page-budget.test.ts +12 −2
@@ -1,5 +1,5 @@
11 /**
2 * The page-load budget (#11320): the five pages people open first answer
2 * The page-load budget (#11320): the pages people open first answer
33 * under their median warm, on a seeded forge booted in-process and walked
44 * signed in, and run no more SQL statements than `src/perf/page_budget.ts`
55 * allows.
@@ -14,6 +14,7 @@ import { afterAll, beforeAll, expect, test } from "bun:test";
1414 import { mkdtempSync, rmSync } from "node:fs";
1515 import { tmpdir } from "node:os";
1616 import { join } from "node:path";
17 import { openPull } from "../src/actions/pulls.ts";
1718 import { commitToBranch, createRepo } from "../src/actions/repos.ts";
1819 import { createApp, type App } from "../src/app.ts";
1920 import { createOrg } from "../src/core/orgs.ts";
@@ -74,6 +75,14 @@ beforeAll(async () => {
7475 ],
7576 });
7677 if (!files.ok) throw new Error(JSON.stringify(files.error));
78 // A pull, opened before the issues so it is #1: the pull page's row walks `/alice/notes/pulls/1`.
79 const topic = await commitToBranch(app, alice, notes, {
80 branch: "topic", message: "a change", files: [{ path: "NOTES.md", content: "a change\n" }],
81 });
82 if (!topic.ok) throw new Error(JSON.stringify(topic.error));
83 const pull = await openPull(app, alice, notes, { title: "A change", body: "Adds notes.", baseBranch: "main", headBranch: "topic" });
84 if (!pull.ok) throw new Error(JSON.stringify(pull.error));
85 if (pull.value.number !== 1) throw new Error(`the pull is #${pull.value.number}, not #1`);
7786 for (let i = 1; i <= 12; i++) {
7887 const made = createIssue(app.db, { repoId: notes.id, authorId: bob.id, title: `Issue ${i}`, body: "body" });
7988 if (!made.ok) throw new Error(made.error);
@@ -161,10 +170,11 @@ async function time(
161170 return { samples, walls, phases: parsePhases(header) };
162171 }
163172
164 test("the budget table names thirteen pages, each once, with a median and a statement limit", () => {
173 test("the budget table names nineteen pages, each once, with a median and a statement limit", () => {
165174 expect(PAGE_BUDGETS.map((b) => b.pattern)).toEqual([
166175 "/", "/explore", "/map", "/:owner/:name", "/changelog", "/:owner/:name/next",
167176 "/:owner/:name/space", "/:owner/:name/space.json", "/maintenance", "/pricing", "/forges/new", "/claim", "/templates",
177 "/system", "/feed", "/board", "/fleet", "/talk", "/:owner/:name/pulls/:number",
168178 ]);
169179 for (const b of PAGE_BUDGETS) {
170180 expect(b.medianMs).toBeLessThanOrEqual(50);

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs