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

Sentinel: shared:01m23vygyffx5hg2f5vm8r74sr:1le13aox3q is past its budget: trevato/forge: "/map on the forge-sized fixture, warm > stranger: p95 within the wall-clock floor, statements within a … #3023

Merged opened this

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

Merged

scout/forge:scout/2977-sentinel-shared-01m23vygyffx5hg2f5vm8r74 → main 2 commits fork 2 threads · 2 unresolved

  • Merged. scout/2977-sentinel-shared-01m23vygyffx5hg2f5vm8r74 was merged into main as 9652de0.

Review

Sign in to review this change.
1 file changed +19 −6
test/map-cache.test.ts +19 −6
@@ -67,31 +67,44 @@ describe("/map on the forge-sized fixture, warm", () => {
6767 afterAll(() => servers.stop());
6868
6969 for (const who of ["owner", "stranger"] as const) {
70 test(`${who}: p95 within the wall-clock floor, statements within a fixed cost + 2 per lane`, async () => {
70 test(`${who}: warm hits far cheaper than a cold build, statements within a fixed cost + 2 per lane`, async () => {
outdated

The test name still says p95 within the wall-clock floor. Rename it to match what is asserted.

7171 const cookie = who === "owner" ? f.ownerCookie : f.strangerCookie;
72 // Both viewers share one cache, so drop it here: the first request is a
73 // real cold build for this viewer, whichever test ran before.
74 clearMapCache();
75 const coldStarted = performance.now();
7276 const warm = await get(servers, "/map", cookie);
77 const cold = performance.now() - coldStarted;
7378 const lanes = lanesIn(warm);
7479 expect(lanes).toBeGreaterThan(5);
7580 const counter = countStatements(f.app.db);
7681 const times: number[] = [];
77 let statements = 0;
82 const counts: number[] = [];
7883 try {
7984 for (let n = 0; n < 20; n++) {
8085 counter.reset();
8186 const started = performance.now();
8287 await get(servers, "/map", cookie);
8388 times.push(performance.now() - started);
84 statements = Math.max(statements, counter.count);
89 counts.push(counter.count);
8590 }
8691 } finally {
8792 counter.stop();
8893 }
8994 times.sort((a, b) => a - b);
9095 const p95 = times[Math.ceil(times.length * 0.95) - 1]!;
96 const median = times[times.length >> 1]!;
97 // The steady state: a lane's minute or the UTC day turning over mid-loop
98 // rebuilds one request, and that is the cache working, not failing.
99 counts.sort((a, b) => a - b);
100 const statements = counts[counts.length >> 1]!;
91101 console.log(`${who}: ${lanes} lanes, p95 ${p95.toFixed(1)} ms, ${statements} statements`);
92 // 200 ms is the floor test/flake.test.ts allows a request; the budget
93 // in the doc (50 ms) is read off bench/map-home.ts, not asserted here.
94 expect(p95).toBeLessThan(200);
102 // Wall-clock is the check machine's, so it is only ever a ratio between
103 // two timings taken here, a real cold build and the warm median: a
outdated

The cold sample is not cold for the stranger (shared cache), and one sample against a median of 20 is noisy. Call clearMapCache() before the timed first request and assert a ratio, for example median * 3 < cold. The 5 ms floor is itself a machine-load bound.

104 // missing cache puts them level. The doc's 50 ms budget is read off
105 // bench/map-home.ts. p95 below is a hang guard, nothing more.
106 expect(median * 3).toBeLessThan(cold);
107 expect(p95).toBeLessThan(5_000);
95108 // The page's own chrome costs a fixed ~25 statements (session, settings,
96109 // the repository lists); a lane costs at most two. Cold, it was ~2,700.
97110 expect(statements).toBeLessThanOrEqual(CHROME + 2 * lanes);

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs