Skip to content

[codex] Prewarm route transform workers#61

Draft
ScriptedAlchemy wants to merge 3 commits into
codex/lazy-route-worker-poolfrom
codex/prewarm-route-workers
Draft

[codex] Prewarm route transform workers#61
ScriptedAlchemy wants to merge 3 commits into
codex/lazy-route-worker-poolfrom
codex/prewarm-route-workers

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Collaborator

Summary

  • Keep route transform worker slots lazy so dev startup no longer creates the whole pool on the first transform executor use.
  • Prewarm the full route transform worker pool from onAfterCreateCompiler in dev mode, before lazy route compilation requests hit the executor.
  • Add coverage for lazy slot creation and explicit prewarm behavior.

Why

The first parallel transform implementation could defer web/node environment builds, but route transform workers still had a startup cliff. Pure lazy worker slots improved initial dev server readiness, but browsing into lazy-compiled routes could still pay worker creation cost. I tested full-pool and yielded/batched prewarm variants to find the best tradeoff.

Benchmark Notes

Large dev benchmark medians from local runs on this machine:

Variant wall ms ready ms route total ms wall p95 first route ms
old custom worker baseline 8570.3 5787.5 2576.0 9039.4 2301.3
lazy worker slots 7431.2 4957.3 2342.6 7742.1 2084.0
prewarm on onAfterCreateCompiler 7417.9 4872.7 2354.5 7670.0 2094.2
yielded prewarm 7509.4 5001.2 2335.3 7592.5 2071.7
prewarm on onBeforeDevCompile 7828.3 5009.6 2366.7 8138.8 2105.9
batched yielded prewarm 7711.4 5048.0 2463.8 8805.8 2193.4

onAfterCreateCompiler full-pool prewarm was the best overall choice: fastest median wall and ready time among the tried prewarm variants, with better p95 than lazy-only, while avoiding lazy route requests being the first thing to create worker slots.

Validation

  • pnpm exec tsc --noEmit
  • pnpm test tests/parallel-route-transforms.test.ts tests/index.test.ts tests/features.test.ts tests/build-output-transforms.test.ts
  • pnpm build
  • git diff --check

@pkg-pr-new

pkg-pr-new Bot commented Jun 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/rsbuild-plugin-react-router@f6f5a93

commit: f6f5a93

@ScriptedAlchemy ScriptedAlchemy changed the base branch from main to codex/lazy-route-worker-pool June 27, 2026 05:58
@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Benchmark Results

Compared PR head 668fbf8 against base 6a49a94.

Total median wall time: 12.24s -> 12.10s (-1.1%, 1.01x speedup)
Compiler ready median: 10.04s -> 9.94s (-0.9%)
Route load median: 2.14s -> 2.08s (-2.9%)

Benchmark Base total Head total Delta Head ready Head routes Speedup Head RSS p95
large-355-ssr-esm 12.24s 12.10s -1.1% 9.94s 2.08s 1.01x -

Profile: large; mode: dev; iterations: 10; warmup: 0.
Workflow run

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