Public: anyone can read this; the crew can change it.
/explore's rank phase stays under 15 ms with 500 public repositories #4011
Check · Review · Land · Live done — Landed and live in production.
`/explore` now reuses its ranking until the forge's write clock moves, so a warm request's rank phase is one statement. That cache was already on the branch from earlier work. This run only merged current `main` into the branch and pushed it.
shipped production is serving it deploy 28f939d
/explore now reuses its ranking until the forge's write clock moves, so a warm request's rank phase is one statement. That cache was already on the branch from earlier work. This run only merged current main into the branch and pushed it.
I couldn't type-check here. bun install and bun x tsc both failed with a read-only temp directory error, so the forge's check will be the first type check.
What changed (earlier commits)
src/actions/explore.tskeeps the ranking until the write clock moves, so a new star or push shows on the next request.- The cache is keyed on admin standing too. Admins get the same cached rank, with spawned forges added after the kept read, and the kept rows are frozen.
test/explore-rank.test.tsseeds 500 public repositories with a week of activity and asserts four things: the warm rank phase is under 15 ms, a cold-versus-warm run issues fewer statements, the ranked order is unchanged, and private and sealed repositories never appear.
What I did this run
- I merged
maininto the branch. The history had fallen far behindmain, which may be why the parked check failed. - I tried a rebase first, but it would have needed a force push, which is refused here.
bun test test/explorepasses: 15 tests across 3 files, 0 failures.
What I left out
- I didn't change the query itself to a single bounded one; the cache is the whole fix.
To try it: load /explore twice and compare rank;dur in the Server-Timing header, or run bun test test/explore-rank.test.ts.
Works in the preview: /explore answers 200 with rank;dur 0.2-0.8 ms warm (one 4.3 ms outlier), well under 15 ms. The cache is keyed on viewer id and admin standing, invalidated by the write clock with a 5 s ceiling, rows are frozen, and spawned forges are read fresh and merged after the kept read, so no private row crosses viewers. Page, API and MCP all go through explore(), so the terminal/page parity is unchanged. Two things I would do next: (1) the wall-clock assertions in test/explore-rank.test.ts (warm*5 < cold, warm < 15 ms) can flake on a loaded CI box; keep the statement-count tests as the hard guard and loosen or drop the ratio. (2) The admin test ends with only length <= 60, which proves nothing about forge rows sorting among kept rows; assert the forge row appears for kind:all with a query that matches it, and add a guest-vs-member case showing a private repo never reaches a guest from a member warm entry.
/explorenow reuses its ranking until the forge's write clock moves, so a warm request's rank phase is one statement. That cache was already on the branch from earlier work. This run only merged currentmaininto the branch and pushed it.I couldn't type-check here.
bun installandbun x tscboth failed with a read-only temp directory error, so the forge's check will be the first type check.What changed (earlier commits)
src/actions/explore.tskeeps the ranking until the write clock moves, so a new star or push shows on the next request.test/explore-rank.test.tsseeds 500 public repositories with a week of activity and asserts four things: the warm rank phase is under 15 ms, a cold-versus-warm run issues fewer statements, the ranked order is unchanged, and private and sealed repositories never appear.What I did this run
maininto the branch. The history had fallen far behindmain, which may be why the parked check failed.bun test test/explorepasses: 15 tests across 3 files, 0 failures.What I left out
To try it: load
/exploretwice and comparerank;durin theServer-Timingheader, or runbun test test/explore-rank.test.ts.Closes #3394