You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(router): cold-start at route scale — manifest sharding per prefix, or a documented warmup pattern #665
At 26,363 routes the deployed worker's very first request costs ~646ms vs a ~23ms warm floor (BENCHMARK-2026-07-04-edge-26k.md, n=1 post-deploy, CF-reported isolate startup 78ms). The cost concentrates in first-request work:
the routes-manifest chunk (5.7MB raw at this scale) is JSON.parsed once on the first request via the lazy manifest loader (src/vite/discovery/virtual-module-codegen.ts registerRouterManifestLoader);
the named-routes chunk (1.15MB) is statically imported by the worker entry, so it is inside the 78ms startup;
each include group then pays chunk eval on its own first hit, scaling with routes-per-chunk: 188ms for the ~9k-route group, 137ms for ~5k, ~75ms for a 240-route group.
Per-request matching is flat (trie), so cold start is where route count now costs — and it is paid by one unlucky user per isolate.
Directions (independent levers)
Manifest sharding per include prefix: emit the precomputed trie/entries per group so the first request parses root + the target group only, not the whole table. Biggest structural win; interacts with the bundle-hygiene rule that generated route data lives in exactly one (lazy) chunk — sharding means one lazy chunk per group instead.
Lazy-parse trie subtrees: keep one chunk but defer JSON.parse of per-group subtrees until first touch.
Short-term, docs-only: document a post-deploy warmup ping pattern (hit each include prefix once after deploy) in the deployment-facing skills. The stress app's bench harness already does exactly this sequence (bench/scenarios.ts coldStartPaths).
Evidence
tests/cloudflare-stress-demo/BENCHMARK-2026-07-04-edge-26k.md — cold table (646ms first request; per-chunk first-hit costs) and methodology (bench/run.ts --url right after wrangler deploy).
Cold-start at route scale was addressed without per-prefix trie sharding.
Cloudflare Text-module externalization of large tries (src/vite/discovery/virtual-module-codegen.ts; e2e tests/cloudflare-basic/e2e/manifest-text-module.test.ts) — this is the structural win, and it keeps Bundle Hygiene rule Router idea 2 revisit #1 (one lazy data chunk per router).
Documented post-deploy warmup ping for async-include prefixes (skills/composability/SKILL.md), matching the stress-app bench harness.
Reopen if Text-module + warmup still leave a first-request cliff that justifies a bundle-hygiene exception for sharded tries.
Activity
perf(vite): ship route-manifest data through a runtime channel on bot…
perf(vite): ship route manifest as a workerd Text module on cloudflar…
perf(vite): ship route manifest as a workerd Text module on cloudflar…
ivogt commentedon Aug 30, 2026
Cold-start at route scale was addressed without per-prefix trie sharding.
src/vite/discovery/virtual-module-codegen.ts; e2etests/cloudflare-basic/e2e/manifest-text-module.test.ts) — this is the structural win, and it keeps Bundle Hygiene rule Router idea 2 revisit #1 (one lazy data chunk per router).skills/composability/SKILL.md), matching the stress-app bench harness.Reopen if Text-module + warmup still leave a first-request cliff that justifies a bundle-hygiene exception for sharded tries.