Separate Start cold-graph cost from per-request cost - #1675
Merged
Conversation
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.
Contributor
Cloudflare previewTorn down — the PR is closed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The accepted explanation (#1628) is that Start's lazy
loadEntriesimport 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.dispatchruns 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
fetchHandlerto recordwasWarm(false only for the first Start-handled request in an isolate) andhandlerMs. 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.