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

The signed-in feed's first paint answers under 50 ms warm, measured by a test that fails above it #16599

Merged opened this

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

Merged

I extended test/feed-budget.test.ts so the feed page and its JSON are each held to a 50 ms median, and nothing was over budget. bun test test/feed-budget.test.ts passes (8 tests) and bun x tsc --noEmit and bun scripts/gate.ts --fix are clean. I did not run any other test file.

Notes

shipped production is serving it deploy 3256dd5

opened this

I extended test/feed-budget.test.ts so the feed page and its JSON are each held to a 50 ms median, and nothing was over budget. bun test test/feed-budget.test.ts passes (8 tests) and bun x tsc --noEmit and bun scripts/gate.ts --fix are clean. I did not run any other test file.

What changed

  • Page and JSON: the file already timed /feed and / over 500 posts, but it took a minimum or a median of three and never touched /api/v1/feed. It now also takes the median of nine warm runs for GET /feed and for GET /api/v1/feed. Each fails at 50 ms or more. The budget (MEDIAN_BUDGET_MS = 50) is written in the test.
  • First page only: a new test checks that the JSON returns a first page of items, not all 500.

What I chose not to do

  • Seed size: I kept the file's 500-post seed, not 200, because it is the heavier case and a lower count would be a weaker test.
  • What is timed: the server's own app phase from Server-Timing, not client wall time. It is the same measure the repository's other feed budget tests use, and it is steadier on a loaded machine.
  • Slowest query: no query needed naming or fixing, because both stayed under budget.
  • Helper reuse: I reused median from test/helpers/page_budget.ts.

How to try it: bun test test/feed-budget.test.ts.

Closes #16302

1 earlier comment · 1 event
commented

I extended test/feed-budget.test.ts so the feed page and its JSON are each held to a 50 ms median, and nothing was over budget. bun test test/feed-budget.test.ts passes (8 tests) and bun x tsc --noEmit and bun scripts/gate.ts --fix are clean. I did not run any other test file.

What changed

  • Page and JSON: the file already timed /feed and / over 500 posts, but it took a minimum or a median of three and never touched /api/v1/feed. It now also takes the median of nine warm runs for GET /feed and for GET /api/v1/feed. Each fails at 50 ms or more. The budget (MEDIAN_BUDGET_MS = 50) is written in the test.
  • First page only: a new test checks that the JSON returns a first page of items, not all 500.

What I chose not to do

  • Seed size: I kept the file's 500-post seed, not 200, because it is the heavier case and a lower count would be a weaker test.
  • What is timed: the server's own app phase from Server-Timing, not client wall time. It is the same measure the repository's other feed budget tests use, and it is steadier on a loaded machine.
  • Slowest query: no query needed naming or fixing, because both stayed under budget.
  • Helper reuse: I reused median from test/helpers/page_budget.ts.

How to try it: bun test test/feed-budget.test.ts.

Changes requested — before the latest push

The JSON budget and the first-page test are good and in the right file. One round of changes, all about there being one way to state the budget:

  1. /feed is now held to the budget twice. The new nine-run median test covers it, so remove the older "the warm first paint holds the budget" test (line 65), which takes the minimum of three and passes on one lucky run. The pull should replace the weaker check, not sit beside it.
  2. MEDIAN_BUDGET_MS = 50 repeats BUDGET_MS = 50 at the top of the file. Keep one constant and use it in the new tests.
  3. The / test (median of three, lines 92-97) is a third copy of the same loop. Fold it into the for (const path of [...]) loop with the nine-run median: ["/", "/feed", "/api/v1/feed"].

Fine as is: the 500-item seed is heavier than the 200 in box 1, and timing the server's app phase is steadier than client wall time. I did not read the head against the issue boxes for ticks, since I am requesting changes.

commented

test/feed-budget.test.ts now states the 50 ms budget once. I made all three changes @juniper asked for and pushed them to the same branch.

  • Old /feed test: I removed "the warm first paint holds the budget", the minimum-of-three check, so the nine-run median is now the only /feed check.
  • One constant: MEDIAN_BUDGET_MS is gone and the new tests use BUDGET_MS.
  • One loop: I removed the three-run median test for /. One loop now covers ["/", "/feed", "/api/v1/feed"], each taking the median of nine warm runs of the server's app phase, under 50 ms.

The file's 7 tests pass, and bun x tsc --noEmit and bun scripts/gate.ts --fix are clean. I did not run any other test file.

I agree with all three points and have nothing to dispute.

Approved

All three earlier asks are met: the minimum-of-three /feed test is gone, there is one BUDGET_MS constant, and one loop covers /, /feed and /api/v1/feed with the median of nine warm app phases. The file's 7 tests pass here. This is a test-only change, so there is no page to try in the preview. The seed is 500 items, heavier than the 200 the issue names, which makes the test stricter. Nothing is blocking. Two things I would do next: (1) Non-blocking: on a real slowdown the failure message only shows the median, so print the nine runs when it fails, which would help whoever has to name the slow query. (2) Non-blocking: add a signed-out case, if that is a different path, so the first paint of a guest is held to the same budget.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs