Public: anyone can read this; the crew can change it.
The signed-in front door with 500 feed posts answers in under 50 ms, and says where the time goes in Server-Timing #15774
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/15766-the-signed-in-front-door-with-500-feed-p → main 0 commits fork 2 threads · 2 unresolved
2 files
changed +20
−1
src/web/pages/home_flow.ts +5 −1
| @@ -523,9 +523,13 @@ export async function homeFlowPage(ctx: Ctx, known?: { readonly spawned: Awaited | ||
| 523 | 523 | const only = filterOf(ctx.url); |
| 524 | 524 | const mine = waitsOf(ctx.url); |
| 525 | 525 | const now = Date.now(); |
| 526 | const reading = performance.now(); | |
| 526 | 527 | const picture = await timePhaseAsync(ctx.request, "picture", () => lanePicture(ctx.app.db, optionsOf(ctx), "page", now)); |
| 527 | const rendering = performance.now(); | |
| 528 | 528 | const viewing = picture === undefined ? undefined : timePhase(ctx.request, "viewing", () => viewFor(ctx.app.db, user, picture, view === "table" ? null : only, mine ? waitingOnMe(ctx, user) : undefined)); |
| 529 | // The whole read, named as one stretch that contains picture and viewing: do not sum it with them | |
| 530 | // (#15766). | |
| 531 | notePhase(ctx.request, "read-total", performance.now() - reading); | |
| 532 | const rendering = performance.now(); | |
| 529 | 533 | // A spawned forge's owner is a client: the forge-wide figures are not theirs to see, whole home |
| 530 | 534 | // or lean. |
| 531 | 535 | const spawned = known !== undefined ? known.spawned : await timePhaseAsync(ctx.request, "spawned", () => spawnedForge(ctx.app)); |
test/feed-budget.test.ts +15
| @@ -12,6 +12,7 @@ import { createUser, type User } from "../src/core/users.ts"; | ||
| 12 | 12 | import { createSession } from "../src/core/sessions.ts"; |
| 13 | 13 | import { serve, type Servers } from "../src/http/server.ts"; |
| 14 | 14 | import { promote } from "./helpers/members.ts"; |
| 15 | import { median } from "./helpers/page_budget.ts"; | |
| 15 | 16 | |
| 16 | 17 | const SEEDED = 500; |
| 17 | 18 | const BUDGET_MS = 50; |
| @@ -80,3 +81,17 @@ test("the first thirty posts are in the HTML, and no script fetches them", async | ||
| 80 | 81 | expect(html).not.toMatch(/fetch\(\s*['"`]\/api\/v1\/feed(?!\/)/); |
| 81 | 82 | expect(html).toMatch(/href="[^"]*cursor=/); |
| 82 | 83 | }); |
| 84 | ||
| 85 | // The signed-in front door itself (#15766): `/` is the feed, so it is held to the same budget. | |
| 86 | test("GET / names its read-total and render phases in Server-Timing", async () => { | |
| 87 | const { timing } = await look("/"); | |
| 88 | const names = timing.split(", ").map((p) => p.split(";")[0]); | |
| 89 | expect(names).toEqual(expect.arrayContaining(["read-total", "render"])); | |
| 90 | }); | |
| 91 | ||
| 92 | test("GET / with 500 posts: the median of three warm answers is under 50 ms", async () => { | |
| 93 | await look("/"); | |
| 94 | const runs: number[] = []; | |
| 95 | for (let i = 0; i < 3; i++) runs.push(Number(/(?:^|, )app;dur=([\d.]+)/.exec((await look("/")).timing)![1])); | |
| 96 | expect(median(runs)).toBeLessThan(BUDGET_MS); | |
Next: wall time includes client fetch and body read; prefer the app;dur from Server-Timing like the /feed budget test, which is steadier on a loaded runner. |
||
| 97 | }); |
new above
offline
Next: read spans picture+viewing, so summing the phases double counts. Consider a desc on the phase noting it contains the others.