Start: prerender.concurrency does not parallelize CPU-bound page rendering
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- node.js, typescript, vite
調査の方向性
The issue is in start-plugin-core/src/vite/prerender.ts in the startPreviewServer function. Examine how the prerender queue is processed and how the preview server is invoked. Look at the linked issue #8430 which moves prerender preview into a Node worker, as a potential starting point for parallelization. The reproducer repository includes a benchmark to test changes. 'Done' means prerendering CPU-bound pages scales with the concurrency setting across multiple cores.
索引モデルが issue の本文から書いたものです。
説明
Which project does this relate to?
Start
Describe the bug
prerender.concurrency suggests pages are rendered in parallel, but prerendering sends every page to one preview server (startPreviewServer in start-plugin-core/src/vite/prerender.ts). That server runs SSR in a single JavaScript thread, so concurrency only overlaps I/O waits; the rendering work of each page still happens one page at a time. For sites with many CPU-bound pages, build time grows linearly with page count, and raising concurrency changes nothing.
This isn't adapter-specific. The reproducer uses plain Start with the default Node preview server. With @cloudflare/vite-plugin the preview is one workerd process running one isolate, so the effect is the same.
Real-world impact: in a production app with ~19k prerendered pages (CPU-bound renders from bundled static data, no network I/O), prerendering takes ~110–150s locally at concurrency 1, 2 or 4 alike. In CI (Cloudflare Workers Builds, 4 vCPU) the full build went from ~1 min to ~5 min once all pages were prerendered.
As an experiment I split the same pages across 4 separate preview processes (N workerd instances started against the built dist/server). The output matched the built-in prerenderer's, except for the dehydration timestamp, and prerendering dropped to ~45s, scaling with process count (1 → 2 → 4) up to the machine's performance cores. I'd rather not maintain that workaround, since it depends on internals and unstable APIs, so an official option would be great.
Complete minimal reproducer
https://github.com/R4ULtv/tanstack-start-prerender-concurrency
Steps to Reproduce the Bug
git clone https://github.com/R4ULtv/tanstack-start-prerender-concurrency && cd tanstack-start-prerender-concurrencynpm installnpm run bench. This runsvite buildwithprerender.concurrencyset to 1, 4 and the machine's core count, and prints the time of each build. The app has one route,/page/$id, whose loader does ~15 ms of synchronous CPU work, with 1,000 pages prerendered (PAGE_COUNTto change).
Result on an Apple M-series Mac (10 logical cores, Node 24):
| concurrency | build time |
|---|---|
| 1 | 21.3s |
| 4 | 20.4s |
| 10 | 19.6s |
Expected behavior
With concurrency > 1 on a multi-core machine, prerendering CPU-bound pages should get faster. For example:
- an option such as
prerender.workers: numberthat starts N preview servers (worker threads or child processes) and spreads the page queue across them; or, at least, - documentation stating that
concurrencyonly overlaps I/O and doesn't parallelize rendering.
Screenshots or Videos
No response
Platform
- Router / Start Version: @tanstack/react-start 1.168.57, @tanstack/react-router 1.170.38
- OS: macOS 15 (Darwin 24.6.0), Apple M-series (4 performance + 6 efficiency cores)
- Browser: N/A (build-time issue)
- Browser Version: N/A
- Bundler: vite
- Bundler Version: 8.3.0
Additional context
- #8430 moves the prerender preview into a Node worker, which may be a natural place to start several workers.
- Each page is requested with a trailing slash first (
/page/X/→ 307 →/page/X), which doubles the number of requests during prerendering. Possibly related to #7070 / #6978. - With
@cloudflare/vite-plugin, several local workerd instances started side by side hitSQLITE_BUSYon the shared.wrangler/stateuntil persistence was disabled per instance. That may need coordinating with the Cloudflare plugin if several preview servers are started.
- 主要言語
- TypeScript
- スター
- 15.3k
- フォーク
- 1.9k
- 平均マージ
- 1日 5時間
- マージ済み PR(30日)
- 46
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TanStack/router のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
Masked navigation drops the first character of the hash each time (__tempLocation hash missing '#')対応中かも @hassanabrar202 が 8 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
router-generator: lazy-load Prettier (costs ~300–450ms per build even when formatting is off)対応中かも @Sheraff が 27 日前に担当しました。 オープンpackage: router-generator performance
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
router-generator: sibling `physical()` subtrees in a virtual route config generate duplicate identifiers対応中かも @Sheraff が 27 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
docs(router): clarify static title fallback in SPA mode対応中かも @Rohan-Dedhia が 18 日前に担当しました。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
TanStack/router の issue をすべて見る
似ている issue
-
[Docs] CONTRIBUTING points the Backend Remake milestone at a branch that does not exist対応中かも @franpts2 が今日担当しました。 オープンdocs
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
メンテナーはふだん 3 日以内に返信
-
ready-for-agent
難易度 2/5 半日 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
cloudflare/nimbus#423 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
[BUG]: Shared links drop the configured basePath on GitHub Pages対応中かも @anshulchikhale30-p が今日担当しました。 オープンbug
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
StabilityNexus/IdentityTokens-EVM-Frontend#182 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信