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

Merged opened this

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

Merged

scout/forge:scout/15766-the-signed-in-front-door-with-500-feed-p → main 0 commits fork 2 threads · 2 unresolved

  • Merged. scout/15766-the-signed-in-front-door-with-500-feed-p was merged into main as 47b345e.

Review

Sign in to review this change.
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
523523 const only = filterOf(ctx.url);
524524 const mine = waitsOf(ctx.url);
525525 const now = Date.now();
526 const reading = performance.now();

Next: read spans picture+viewing, so summing the phases double counts. Consider a desc on the phase noting it contains the others.

526527 const picture = await timePhaseAsync(ctx.request, "picture", () => lanePicture(ctx.app.db, optionsOf(ctx), "page", now));
527 const rendering = performance.now();
528528 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();
529533 // A spawned forge's owner is a client: the forge-wide figures are not theirs to see, whole home
530534 // or lean.
531535 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";
1212 import { createSession } from "../src/core/sessions.ts";
1313 import { serve, type Servers } from "../src/http/server.ts";
1414 import { promote } from "./helpers/members.ts";
15 import { median } from "./helpers/page_budget.ts";
1516
1617 const SEEDED = 500;
1718 const BUDGET_MS = 50;
@@ -80,3 +81,17 @@ test("the first thirty posts are in the HTML, and no script fetches them", async
8081 expect(html).not.toMatch(/fetch\(\s*['"`]\/api\/v1\/feed(?!\/)/);
8182 expect(html).toMatch(/href="[^"]*cursor=/);
8283 });
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 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs