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

Home's Server-Timing names its regions: feed, KPI row, pinned panels, shelf #3181

Merged opened this

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

Merged

`/` now names its regions in `Server-Timing`, with `desc="hit"` on a phase whose cache answered. The new test and the existing home, route-timing and map-cache tests pass. I couldn't run the type check here (`bun x tsc` can't write to its temp dir and the `bun` types are missing), so the forge's check will be its first run.

shipped production is serving it deploy 4915f35

opened this

/ now names its regions in Server-Timing, with desc="hit" on a phase whose cache answered. The new test and the existing home, route-timing and map-cache tests pass. I couldn't run the type check here (bun x tsc can't write to its temp dir and the bun types are missing), so the forge's check will be its first run.

  • Phases: a signed-in home records feed, kpis and panels. The anonymous door records shelf.
  • No phase for a hidden region: kpis and panels are recorded only where the page renders them (admin, not the lean first-steps view). A non-admin gets feed alone, and an anonymous visitor gets shelf alone.
  • Hit marking: src/core/route_timing.ts gains timePhase and timePhaseAsync. They mark a phase as a hit when the cache's hit count rose and its miss count didn't. Under concurrent requests a hit can be credited to the neighbouring request.
  • feed scope: it times the whole region (ranking and rendering), with the candidate cache inside it.
  • Test: test/home-timing.test.ts checks the three viewers and that a warm owner's kpis and feed carry desc="hit". It also checks the header format for a hit and a miss.
  • Docs: docs/CACHING.md has a "Where home's time goes" section with one run from the new bench/home-phases.ts. The owner's p50 and p95 are app 15.3 and 19.7 ms, feed 7.1 and 10.0, kpis 0.2 and 0.3, panels 0.1 and 0.1.

Left out: the issue didn't ask for a session phase on /, so I didn't add one. The shelf phase wraps the front-page read and building the tiles, not the final render.

Try it: bun test test/home-timing.test.ts, or bun run bench/home-phases.ts to print the table. Or load / and read the Server-Timing response header.

Closes #3160

commented

/ now names its regions in Server-Timing, with desc="hit" on a phase whose cache answered. The new test and the existing home, route-timing and map-cache tests pass. I couldn't run the type check here (bun x tsc can't write to its temp dir and the bun types are missing), so the forge's check will be its first run.

  • Phases: a signed-in home records feed, kpis and panels. The anonymous door records shelf.
  • No phase for a hidden region: kpis and panels are recorded only where the page renders them (admin, not the lean first-steps view). A non-admin gets feed alone, and an anonymous visitor gets shelf alone.
  • Hit marking: src/core/route_timing.ts gains timePhase and timePhaseAsync. They mark a phase as a hit when the cache's hit count rose and its miss count didn't. Under concurrent requests a hit can be credited to the neighbouring request.
  • feed scope: it times the whole region (ranking and rendering), with the candidate cache inside it.
  • Test: test/home-timing.test.ts checks the three viewers and that a warm owner's kpis and feed carry desc="hit". It also checks the header format for a hit and a miss.
  • Docs: docs/CACHING.md has a "Where home's time goes" section with one run from the new bench/home-phases.ts. The owner's p50 and p95 are app 15.3 and 19.7 ms, feed 7.1 and 10.0, kpis 0.2 and 0.3, panels 0.1 and 0.1.

Left out: the issue didn't ask for a session phase on /, so I didn't add one. The shelf phase wraps the front-page read and building the tiles, not the final render.

Try it: bun test test/home-timing.test.ts, or bun run bench/home-phases.ts to print the table. Or load / and read the Server-Timing response header.

Approved

Home now names feed, kpis, panels and shelf in Server-Timing, and only for regions the viewer is shown. A phase carries desc="hit" when its cache answered. Phase names are fixed tokens, no viewer text reaches the header, and the page markup is unchanged. That means no design-system, JS-off or phone impact. The tests cover owner, non-admin and anonymous viewers, a warm hit, and the header format. I could not curl the preview (403 from my sandbox) and judged from the source and the tests. Next two things: (1) studioDoor assigns tiles from inside the timePhase closure, so the shelf phase mixes a read with tile building. Return both from the closure, or time only frontPage, and drop the let. (2) The hit credit is read from shared cache counters and can go to a neighbouring request. The docs say so, but a per-call hit flag from Stamped.get would make it exact.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs