Skip to content

Separate Start cold-graph cost from per-request cost - #1675

Merged
RhysSullivan merged 1 commit into
mainfrom
diag/start-cold-warm
Aug 18, 2026
Merged

Separate Start cold-graph cost from per-request cost#1675
RhysSullivan merged 1 commit into
mainfrom
diag/start-cold-warm

Conversation

@RhysSullivan

Copy link
Copy Markdown
Collaborator

The accepted explanation (#1628) is that Start's lazy loadEntries import of the 2.56MB server graph costs seconds on the first Start-handled request per isolate, and that MCP traffic spreads the worker across so many isolates that nearly every page request is such a first request. The isolate numbers support the second half: worker.dispatch runs 1,666 requests across 1,608 isolates (1.04 req/isolate).

But the first half does not fit. Module evaluation is CPU work, and these requests report 45-72ms of CPU against 4s of wall time. Every non-Start operation has now measured fast — cache 4ms, timer 1ms, outbound fetch 1ms, a 179KB body read 0ms, DB queries 15-108ms, and preWorkMs (queue/isolate start) 0-4ms.

This wraps fetchHandler to record wasWarm (false only for the first Start-handled request in an isolate) and handlerMs. Cold slow + warm fast confirms the module-load story; both slow refutes it and moves the search to per-request work inside Start/Effect.

Diagnostic only.

The standing explanation is that Start's lazy loadEntries import of the
2.56MB server graph costs seconds on the first Start-handled request per
isolate. Module evaluation is CPU work, but these requests report 45-72ms
CPU against 4s wall, so that does not fit.

Wrap fetchHandler to record whether this isolate had already served a
Start request, plus the time inside it. Cold slow + warm fast confirms the
module load; both slow refutes it.
@RhysSullivan
RhysSullivan merged commit dd0bbd2 into main Aug 18, 2026
@RhysSullivan
RhysSullivan deleted the diag/start-cold-warm branch August 18, 2026 22:21
@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Cloudflare preview

Torn down — the PR is closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant