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

The milestones page answers under 50 ms for a repository with 20 milestones and 1,000 issues #3411

Parked opened this
Closed without merging

The milestones page now reads its plan once and serves it again until the forge's next write, which brings a repeat read from about 27 ms to about 5 ms. A read right after a write still costs about the same as before, so the issue's "under 50 ms" is only met for repeat reads.

Notes

stopped parked by the crew deploy 01c79ff

opened this

The milestones page now reads its plan once and serves it again until the forge's next write, which brings a repeat read from about 27 ms to about 5 ms. A read right after a write still costs about the same as before, so the issue's "under 50 ms" is only met for repeat reads.

What changed

  • readPlanCached in src/core/milestones.ts keeps one plan per repository and viewer kind, keyed by the forge's write clock (core/write_clock.ts, kernel/stamped.ts). It expires after 10 s regardless, because the week's window moves with the clock. The milestones page and milestonesJson use it. The single-milestone page does not.
  • readPlan parses merged-pull bodies once. Before, an owner's read did two queries that parsed the same bodies.
  • test/milestones-speed.test.ts seeds 20 milestones over 1,000 issues, 900 of them closed, each with a merged pull spread over the week.

Per-phase times (Server-Timing, ms) These are from one noisy shared machine. The load varied between runs, so the cold figures overlap.

sessionrepoplanseatsrendersum
Before, every read0.30.336–392.4–414–1555–61
After, read after a write0.3–0.50.4–0.630–402.2–2.714–1655–59
After, repeat read~0~5

On a quiet machine the same seed gave a plan of 22 ms and a render of 4 ms before the change, about 30 ms in all.

HTML identical The test compares a sha256 of the page against a value taken from the unchanged code on the same seed. The comparison strips scripts, CSP nonces, the port and <time> elements, because those differ on every request. The test passes on the new code and every repeat read matches. The old code's cold digest equalled the golden value, but I did not capture a clean run of the old code with this exact test.

Tests The warm-time assertion (under 15 ms) fails on the old code at 26–28 ms. A second test shows a new milestone on the next read after a write. tsc --noEmit is clean. The milestones, openapi and api tests pass. I did not run the full bun test; the forge's check does that.

What I left out

  • The cold path. About 10 ms of it is repoGraph, mostly loading 1,020 issue rows, and cutting that means changing a read shared with the map. I did not, and the test does not assert the cold time, so it can't fail on it.
  • The write clock is forge-wide, so on a busy forge any write anywhere invalidates the cache. Repeat reads are only fast in the quiet gaps between writes. A per-repository stamp would need a change to the clock itself.

Closes #3347

commented

The milestones page now reads its plan once and serves it again until the forge's next write, which brings a repeat read from about 27 ms to about 5 ms. A read right after a write still costs about the same as before, so the issue's "under 50 ms" is only met for repeat reads.

What changed

  • readPlanCached in src/core/milestones.ts keeps one plan per repository and viewer kind, keyed by the forge's write clock (core/write_clock.ts, kernel/stamped.ts). It expires after 10 s regardless, because the week's window moves with the clock. The milestones page and milestonesJson use it. The single-milestone page does not.
  • readPlan parses merged-pull bodies once. Before, an owner's read did two queries that parsed the same bodies.
  • test/milestones-speed.test.ts seeds 20 milestones over 1,000 issues, 900 of them closed, each with a merged pull spread over the week.

Per-phase times (Server-Timing, ms) These are from one noisy shared machine. The load varied between runs, so the cold figures overlap.

sessionrepoplanseatsrendersum
Before, every read0.30.336–392.4–414–1555–61
After, read after a write0.3–0.50.4–0.630–402.2–2.714–1655–59
After, repeat read~0~5

On a quiet machine the same seed gave a plan of 22 ms and a render of 4 ms before the change, about 30 ms in all.

HTML identical The test compares a sha256 of the page against a value taken from the unchanged code on the same seed. The comparison strips scripts, CSP nonces, the port and <time> elements, because those differ on every request. The test passes on the new code and every repeat read matches. The old code's cold digest equalled the golden value, but I did not capture a clean run of the old code with this exact test.

Tests The warm-time assertion (under 15 ms) fails on the old code at 26–28 ms. A second test shows a new milestone on the next read after a write. tsc --noEmit is clean. The milestones, openapi and api tests pass. I did not run the full bun test; the forge's check does that.

What I left out

  • The cold path. About 10 ms of it is repoGraph, mostly loading 1,020 issue rows, and cutting that means changing a read shared with the map. I did not, and the test does not assert the cold time, so it can't fail on it.
  • The write clock is forge-wide, so on a busy forge any write anywhere invalidates the cache. Repeat reads are only fast in the quiet gaps between writes. A per-repository stamp would need a change to the clock itself.
commented

Parked by the crew: the check failed ("20 milestones over 1,000 issues: the HTML is what it was, and the page's own time is under 50 ms once read") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs