Public: anyone can read this; the crew can change it.
The rosters: generate the page budget roster from one file per member (child of #14248) #14438
Check · Review · Land · Live done — Landed and live in production.
torque/forge:torque/14435-the-rosters-generate-the-page-budget-ros → main 3 commits fork
16 files
changed +105
−27
src/checks/tiers.ts +4 −1
| @@ -72,7 +72,10 @@ export const movesPageBudgets = (file: string): boolean => | ||
| 72 | 72 | file === "src/web/layout.ts" || |
| 73 | 73 | file === "src/http/server.ts" || |
| 74 | 74 | file.startsWith("src/web/style/") || |
| 75 | file.startsWith("src/web/pages/"); | |
| 75 | file.startsWith("src/web/pages/") || | |
| 76 | // The table itself (#14435): one file per page under page_budgets/, so a changed limit is judged. | |
| 77 | file === "src/perf/page_budget.ts" || | |
| 78 | file.startsWith("src/perf/page_budgets/"); | |
| 76 | 79 | |
| 77 | 80 | /** What a test the times table does not name is assumed to take. */ |
| 78 | 81 | const UNKNOWN_SECONDS = 5; |
src/perf/page_budget.ts +29 −26
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | /** |
| 2 | 2 | * The page-load budget (#11320, #11360): the pages people open first, each |
| 3 | 3 | * with the median it answers in warm and the SQL statements one request of |
| 4 | * it may run. Plain data, one line per page: add a page in one line here. | |
| 5 | * `test/page-budget.test.ts` walks the table in-process, and a production | |
| 4 | * it may run. Plain data, one file per page in `page_budgets/`: add a page as a file there and a | |
| 5 | * line in the roster below. `test/page-budget.test.ts` walks the table in-process, and a production | |
| 6 | 6 | * probe can read the same table. |
| 7 | 7 | * |
| 8 | 8 | * The statement count is the hard limit: it is the same on a loaded machine |
| @@ -11,6 +11,19 @@ | ||
| 11 | 11 | * before it judges. |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | import { budget as home } from "./page_budgets/home.ts"; | |
| 15 | import { budget as explore } from "./page_budgets/explore.ts"; | |
| 16 | import { budget as map } from "./page_budgets/map.ts"; | |
| 17 | import { budget as app } from "./page_budgets/app.ts"; | |
| 18 | import { budget as changelog } from "./page_budgets/changelog.ts"; | |
| 19 | import { budget as next } from "./page_budgets/next.ts"; | |
| 20 | import { budget as space } from "./page_budgets/space.ts"; | |
| 21 | import { budget as spaceData } from "./page_budgets/space_data.ts"; | |
| 22 | import { budget as maintenance } from "./page_budgets/maintenance.ts"; | |
| 23 | import { budget as pricing } from "./page_budgets/pricing.ts"; | |
| 24 | import { budget as newForge } from "./page_budgets/new_forge.ts"; | |
| 25 | import { budget as claim } from "./page_budgets/claim.ts"; | |
| 26 | ||
| 14 | 27 | export interface PageBudget { |
| 15 | 28 | /** What the page is, in words, for the failure line. */ |
| 16 | 29 | readonly page: string; |
| @@ -25,34 +38,24 @@ export interface PageBudget { | ||
| 25 | 38 | } |
| 26 | 39 | |
| 27 | 40 | /** |
| 41 | * The roster: one file per page in `page_budgets/`, listed here in the order the pages are walked. | |
| 42 | * `test/page-budget-roster.test.ts` fails when this list and the directory differ. | |
| 28 | 43 | * Statement limits are today's count, signed in, plus a little: lower them as pages get cheaper, |
| 29 | 44 | * raise one only on purpose. |
| 30 | 45 | */ |
| 31 | 46 | export const PAGE_BUDGETS: readonly PageBudget[] = [ |
| 32 | { page: "home", pattern: "/", medianMs: 50, statements: 46 }, | |
| 33 | { page: "explore", pattern: "/explore", medianMs: 50, statements: 18 }, | |
| 34 | { page: "map", pattern: "/map", medianMs: 50, statements: 21 }, | |
| 35 | { page: "an app page", pattern: "/:owner/:name", medianMs: 50, statements: 49 }, | |
| 36 | // 21: the release range reads the forge repository's row once, to name its default branch. | |
| 37 | { page: "changelog", pattern: "/changelog", medianMs: 50, statements: 21 }, | |
| 38 | { page: "next up", pattern: "/:owner/:name/next", medianMs: 50, statements: 68 }, | |
| 39 | // The space (#12770), which the owner opens to watch growth: the page and the | |
| 40 | // `space.json` it reads are two requests, so each has its own row. | |
| 41 | // Statement limits: measured warm (15 and 6) plus two, the margin the map row keeps. | |
| 42 | { page: "space", pattern: "/:owner/:name/space", medianMs: 50, statements: 17 }, | |
| 43 | { page: "space data", pattern: "/:owner/:name/space.json", medianMs: 50, statements: 8 }, | |
| 44 | // The admin board of duties (#13388): walked as the admin, stored rows only. Statements: measured | |
| 45 | // warm (53, with main's duties) plus nine: each of the eight duties reads its own state and | |
| 46 | // runs, so the count moves with duty state and background ticks; an N+1 over the duties would | |
| 47 | // still show. Four more duties (flaky-tests #13937, red apps #13938, chapter stall #14057, | |
| 48 | // dead-doc-paths #13977, untested-sources #14125, slow-tests #13966, stale-branches #14141) each | |
| 49 | // read their own state. One query reads every dismissal (#13967). | |
| 50 | { page: "maintenance", pattern: "/maintenance", medianMs: 50, statements: 81 }, | |
| 51 | // A stranger's way to a forge (#11410): walked signed out. `/claim` is | |
| 52 | // measured on a spawned forge with a live link, as the child's owner sees it. | |
| 53 | { page: "pricing", pattern: "/pricing", medianMs: 50, statements: 10, signedOut: true }, | |
| 54 | { page: "new forge", pattern: "/forges/new", medianMs: 50, statements: 14, signedOut: true }, | |
| 55 | { page: "claim", pattern: "/claim", medianMs: 50, statements: 14, signedOut: true }, | |
| 47 | home, | |
| 48 | explore, | |
| 49 | map, | |
| 50 | app, | |
| 51 | changelog, | |
| 52 | next, | |
| 53 | space, | |
| 54 | spaceData, | |
| 55 | maintenance, | |
| 56 | pricing, | |
| 57 | newForge, | |
| 58 | claim, | |
| 56 | 59 | ]; |
| 57 | 60 | |
| 58 | 61 | /** |
src/perf/page_budgets/app.ts added +3
| @@ -0,0 +1,3 @@ | ||
| 1 | import type { PageBudget } from "../page_budget.ts"; | |
| 2 | ||
| 3 | export const budget: PageBudget = { page: "an app page", pattern: "/:owner/:name", medianMs: 50, statements: 49 }; |
src/perf/page_budgets/changelog.ts added +4
| @@ -0,0 +1,4 @@ | ||
| 1 | import type { PageBudget } from "../page_budget.ts"; | |
| 2 | ||
| 3 | // 21: the release range reads the forge repository's row once, to name its default branch. | |
| 4 | export const budget: PageBudget = { page: "changelog", pattern: "/changelog", medianMs: 50, statements: 21 }; |
src/perf/page_budgets/claim.ts added +4
| @@ -0,0 +1,4 @@ | ||
| 1 | import type { PageBudget } from "../page_budget.ts"; | |
| 2 | ||
| 3 | // `/claim` is measured on a spawned forge with a live link, as the child's owner sees it. | |
| 4 | export const budget: PageBudget = { page: "claim", pattern: "/claim", medianMs: 50, statements: 14, signedOut: true }; |
src/perf/page_budgets/explore.ts added +3
| @@ -0,0 +1,3 @@ | ||
| 1 | import type { PageBudget } from "../page_budget.ts"; | |
| 2 | ||
| 3 | export const budget: PageBudget = { page: "explore", pattern: "/explore", medianMs: 50, statements: 18 }; |
src/perf/page_budgets/home.ts added +3
| @@ -0,0 +1,3 @@ | ||
| 1 | import type { PageBudget } from "../page_budget.ts"; | |
| 2 | ||
| 3 | export const budget: PageBudget = { page: "home", pattern: "/", medianMs: 50, statements: 46 }; |
src/perf/page_budgets/maintenance.ts added +6
| @@ -0,0 +1,6 @@ | ||
| 1 | import type { PageBudget } from "../page_budget.ts"; | |
| 2 | ||
| 3 | // The admin board of duties (#13388): walked as the admin, stored rows only. Each duty reads its | |
| 4 | // own state and runs, so the count moves with the number of duties and background ticks; an N+1 | |
| 5 | // over the duties would still show. One query reads every dismissal (#13967). | |
| 6 | export const budget: PageBudget = { page: "maintenance", pattern: "/maintenance", medianMs: 50, statements: 81 }; |
src/perf/page_budgets/map.ts added +3
| @@ -0,0 +1,3 @@ | ||
| 1 | import type { PageBudget } from "../page_budget.ts"; | |
| 2 | ||
| 3 | export const budget: PageBudget = { page: "map", pattern: "/map", medianMs: 50, statements: 21 }; |
src/perf/page_budgets/new_forge.ts added +4
| @@ -0,0 +1,4 @@ | ||
| 1 | import type { PageBudget } from "../page_budget.ts"; | |
| 2 | ||
| 3 | // A stranger's way to a forge (#11410): walked signed out. | |
| 4 | export const budget: PageBudget = { page: "new forge", pattern: "/forges/new", medianMs: 50, statements: 14, signedOut: true }; |
src/perf/page_budgets/next.ts added +3
| @@ -0,0 +1,3 @@ | ||
| 1 | import type { PageBudget } from "../page_budget.ts"; | |
| 2 | ||
| 3 | export const budget: PageBudget = { page: "next up", pattern: "/:owner/:name/next", medianMs: 50, statements: 68 }; |
src/perf/page_budgets/pricing.ts added +4
| @@ -0,0 +1,4 @@ | ||
| 1 | import type { PageBudget } from "../page_budget.ts"; | |
| 2 | ||
| 3 | // A stranger's way to a forge (#11410): walked signed out. | |
| 4 | export const budget: PageBudget = { page: "pricing", pattern: "/pricing", medianMs: 50, statements: 10, signedOut: true }; |
src/perf/page_budgets/space.ts added +5
| @@ -0,0 +1,5 @@ | ||
| 1 | import type { PageBudget } from "../page_budget.ts"; | |
| 2 | ||
| 3 | // The space (#12770), which the owner opens to watch growth. Statements: measured warm (15) plus | |
| 4 | // two. | |
| 5 | export const budget: PageBudget = { page: "space", pattern: "/:owner/:name/space", medianMs: 50, statements: 17 }; |
src/perf/page_budgets/space_data.ts added +5
| @@ -0,0 +1,5 @@ | ||
| 1 | import type { PageBudget } from "../page_budget.ts"; | |
| 2 | ||
| 3 | // The `space.json` the space page reads: its own request, so its own row. Measured warm (6) plus | |
| 4 | // two. | |
| 5 | export const budget: PageBudget = { page: "space data", pattern: "/:owner/:name/space.json", medianMs: 50, statements: 8 }; |
test/check-tiers.test.ts +2
| @@ -305,6 +305,8 @@ describe("the fast set, by measured coverage", () => { | ||
| 305 | 305 | "src/web/style/content.ts", |
| 306 | 306 | "src/http/server.ts", |
| 307 | 307 | "src/web/pages/docs_link.ts", |
| 308 | "src/perf/page_budgets/home.ts", | |
| 309 | "src/perf/page_budget.ts", | |
| 308 | 310 | ]) { |
| 309 | 311 | const plan = fastSet({ ...withBudgets, changed: [file] }); |
| 310 | 312 | for (const budget of PAGE_BUDGET_TESTS) expect(plan.files).toContain(budget); |
test/page-budget-roster.test.ts added +23
| @@ -0,0 +1,23 @@ | ||
| 1 | import { expect, test } from "bun:test"; | |
| 2 | import { readdirSync } from "node:fs"; | |
| 3 | import { PAGE_BUDGETS } from "../src/perf/page_budget.ts"; | |
| 4 | ||
| 5 | const dir = new URL("../src/perf/page_budgets/", import.meta.url); | |
| 6 | ||
| 7 | test("the page budget roster is exactly the files in page_budgets/", async () => { | |
| 8 | const files = readdirSync(dir).filter((f) => f.endsWith(".ts")).sort(); | |
| 9 | const fromDir = await Promise.all(files.map(async (f) => ((await import(new URL(f, dir).href)) as { budget: unknown }).budget)); | |
| 10 | expect(files.length).toBe(PAGE_BUDGETS.length); | |
| 11 | const key = (x: unknown) => JSON.stringify(x); | |
| 12 | expect(fromDir.map(key).sort()).toEqual(PAGE_BUDGETS.map(key).sort()); | |
| 13 | }); | |
| 14 | ||
| 15 | test("every page budget file exports one budget with its own pattern", async () => { | |
| 16 | const seen = new Set<string>(); | |
| 17 | for (const f of readdirSync(dir)) { | |
| 18 | const b = ((await import(new URL(f, dir).href)) as { budget?: { pattern: string } }).budget; | |
| 19 | expect(b?.pattern).toBeTruthy(); | |
| 20 | expect(seen.has(b!.pattern)).toBe(false); | |
| 21 | seen.add(b!.pattern); | |
| 22 | } | |
| 23 | }); |
new above
offline