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
Check · Review · Land · Live done — Landed and live in production.
torque/forge:torque/15251-pages-that-answer-under-a-measured-budge → main 0 commits fork 2 threads · 2 unresolved
15 files
changed +174
−9
docs/design/size-budget.json +24
| @@ -50,5 +50,29 @@ | ||
| 50 | 50 | "/templates": { |
| 51 | 51 | "js": 21760, |
| 52 | 52 | "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 | |
| 53 | 77 | } |
| 54 | 78 | } |
docs/web.md +5 −1
| @@ -32,7 +32,11 @@ The `Speculation-Rules` header points at one hashed rules file: prefetch, modera | ||
| 32 | 32 | |
| 33 | 33 | ## Not done |
| 34 | 34 | |
| 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. | |
| 36 | 40 | |
| 37 | 41 | ## Live regions that keep the reader's place |
| 38 | 42 |
src/checks/tiers.ts +12 −1
| @@ -78,6 +78,15 @@ export const movesPageBudgets = (file: string): boolean => | ||
| 78 | 78 | file === "src/perf/page_budget.ts" || |
| 79 | 79 | file.startsWith("src/perf/page_budgets/"); |
| 80 | 80 | |
| 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 | ||
| 81 | 90 | /** What a test the times table does not name is assumed to take. */ |
| 82 | 91 | const UNKNOWN_SECONDS = 5; |
| 83 | 92 | |
| @@ -297,7 +306,9 @@ export function fastSet(input: FastInput): FastPlan { | ||
| 297 | 306 | for (const [test, why] of input.scans ?? []) take(test, `tree scan: ${why}`); |
| 298 | 307 | } |
| 299 | 308 | 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 | } | |
| 301 | 312 | // What a guess looks for. A test the map has measured already answered |
| 302 | 313 | // for every change the map can see, by what it executes; it is guessed |
| 303 | 314 | // 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"; | ||
| 24 | 24 | import { budget as newForge } from "./page_budgets/new_forge.ts"; |
| 25 | 25 | import { budget as claim } from "./page_budgets/claim.ts"; |
| 26 | 26 | 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"; | |
| 27 | 33 | |
| 28 | 34 | export interface PageBudget { |
| 29 | 35 | /** What the page is, in words, for the failure line. */ |
| 30 | 36 | 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`. */ | |
| 32 | 38 | readonly pattern: string; |
| 33 | 39 | /** The median of 20 warm requests stays under this many ms. */ |
| 34 | 40 | readonly medianMs: number; |
| @@ -58,12 +64,21 @@ export const PAGE_BUDGETS: readonly PageBudget[] = [ | ||
| 58 | 64 | newForge, |
| 59 | 65 | claim, |
| 60 | 66 | templates, |
| 67 | system, | |
| 68 | feed, | |
| 69 | board, | |
| 70 | fleet, | |
| 71 | talk, | |
| 72 | pull, | |
| 61 | 73 | ]; |
| 62 | 74 | |
| 63 | 75 | /** |
| 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. | |
| 66 | 78 | */ |
| 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))); | |
| 69 | 84 | } |
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 { | ||
| 28 | 28 | importsOf, |
| 29 | 29 | landVerdict, |
| 30 | 30 | PAGE_BUDGET_TESTS, |
| 31 | PAGE_TABLE_TESTS, | |
| 31 | 32 | tierLine, |
| 32 | 33 | } from "../src/checks/tiers.ts"; |
| 33 | 34 | import { |
| @@ -384,6 +385,22 @@ describe("the fast set, by measured coverage", () => { | ||
| 384 | 385 | expect(elsewhere.files).not.toContain("test/docs-link.test.ts"); |
| 385 | 386 | }); |
| 386 | 387 | |
| 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 | ||
| 387 | 404 | test("lcov: only src files with a line hit count as executed", () => { |
| 388 | 405 | 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"; |
| 389 | 406 | 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"; | ||
| 12 | 12 | import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; |
| 13 | 13 | import { tmpdir } from "node:os"; |
| 14 | 14 | import { join } from "node:path"; |
| 15 | import { openPull } from "../src/actions/pulls.ts"; | |
| 15 | 16 | import { commitToBranch, createRepo } from "../src/actions/repos.ts"; |
| 16 | 17 | import { createApp, type App } from "../src/app.ts"; |
| 17 | 18 | import { createOrg } from "../src/core/orgs.ts"; |
| @@ -58,6 +59,13 @@ beforeAll(async () => { | ||
| 58 | 59 | ], |
| 59 | 60 | }); |
| 60 | 61 | 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"); | |
| 61 | 69 | const kin = createOrg(app.db, "kin", u.value.id); |
| 62 | 70 | if (!kin.ok) throw new Error(kin.error); |
| 63 | 71 | 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", () => { | ||
| 7 | 7 | expect(pagePath(app, "a b", "x/y")).toBe("/a%20b/x%2Fy"); |
| 8 | 8 | expect(pagePath(PAGE_BUDGETS[0]!, "alice", "notes")).toBe("/"); |
| 9 | 9 | }); |
| 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 () | ||
| 21 | 21 | seen.add(b!.pattern); |
| 22 | 22 | } |
| 23 | 23 | }); |
| 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 @@ | ||
| 1 | 1 | /** |
| 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 | |
| 3 | 3 | * under their median warm, on a seeded forge booted in-process and walked |
| 4 | 4 | * signed in, and run no more SQL statements than `src/perf/page_budget.ts` |
| 5 | 5 | * allows. |
| @@ -14,6 +14,7 @@ import { afterAll, beforeAll, expect, test } from "bun:test"; | ||
| 14 | 14 | import { mkdtempSync, rmSync } from "node:fs"; |
| 15 | 15 | import { tmpdir } from "node:os"; |
| 16 | 16 | import { join } from "node:path"; |
| 17 | import { openPull } from "../src/actions/pulls.ts"; | |
| 17 | 18 | import { commitToBranch, createRepo } from "../src/actions/repos.ts"; |
| 18 | 19 | import { createApp, type App } from "../src/app.ts"; |
| 19 | 20 | import { createOrg } from "../src/core/orgs.ts"; |
| @@ -74,6 +75,14 @@ beforeAll(async () => { | ||
| 74 | 75 | ], |
| 75 | 76 | }); |
| 76 | 77 | 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`); | |
| 77 | 86 | for (let i = 1; i <= 12; i++) { |
| 78 | 87 | const made = createIssue(app.db, { repoId: notes.id, authorId: bob.id, title: `Issue ${i}`, body: "body" }); |
| 79 | 88 | if (!made.ok) throw new Error(made.error); |
| @@ -161,10 +170,11 @@ async function time( | ||
| 161 | 170 | return { samples, walls, phases: parsePhases(header) }; |
| 162 | 171 | } |
| 163 | 172 | |
| 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", () => { | |
| 165 | 174 | expect(PAGE_BUDGETS.map((b) => b.pattern)).toEqual([ |
| 166 | 175 | "/", "/explore", "/map", "/:owner/:name", "/changelog", "/:owner/:name/next", |
| 167 | 176 | "/:owner/:name/space", "/:owner/:name/space.json", "/maintenance", "/pricing", "/forges/new", "/claim", "/templates", |
| 177 | "/system", "/feed", "/board", "/fleet", "/talk", "/:owner/:name/pulls/:number", | |
| 168 | 178 | ]); |
| 169 | 179 | for (const b of PAGE_BUDGETS) { |
| 170 | 180 | expect(b.medianMs).toBeLessThanOrEqual(50); |
new above
offline
isPageTablehas the same body asmovesPageBudgetsjust above it (page_budget.ts or anything under page_budgets/). Two predicates for one concept is clutter, and they will drift. DropisPageTableand usemovesPageBudgetsfor the newfindinfastSet, then update the test and the comment abovePAGE_TABLE_TESTS.