test integrations: investigate time and memory overhead
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- リファクタリング
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- node.js, typescript, vite
- 領域
- backend, performance, testing
調査の方向性
Start with the setup file that imports nitro/app and the serverFetch path, then trace how the test integrations load plugins after vi.mock or rs.mock. The issue lists several follow-up areas: the externals plugin's renderChunk hook, the route-meta and import-attributes plugins, and Rstest's browser globalSetup build. Done means reducing the measured overhead while preserving synchronous useNitroApp() and the stated plugin loading behavior.
索引モデルが issue の本文から書いたものです。
説明
Follow-up to #5101. A quick benchmark there showed that Nitro adds noticeable startup time and memory to test runs, under both Vitest and Rstest.
Findings
An investigation ran generated suites (10, 40 or 120 test files, 4 tests each, with 5, 30 or 150 routes, 3 plugins and a middleware). It used a full build, Node 24, Vitest 5.1 / Vite 8.3, Rstest 0.12.6 and 16 cores. Each runner ran bare (no Nitro), with the plugin installed but unused, and with tests calling serverFetch.
Nitro's added time and main-process memory, compared with the bare run:
| 10 files | 40 files | 120 files | |
|---|---|---|---|
| Added time, Vitest | +420 ms | +660 ms | +1660 ms |
| Added time, Rstest | +325 ms | +625 ms | +1575 ms |
| Added main-process RSS, Vitest | +99 MB | +104 MB | +102 MB |
| Added main-process RSS, Rstest | +124 MB | +132 MB | +173 MB |
- Per test file (main cost on real suites, both runners). Each test-file process pays about 125–155 ms of CPU and 13 MB to load the server stack. Most of it is Node itself (its internal
fetch/Responseimplementation, built-in modules), not Nitro's own code. Test files that never touch Nitro pay it too, because the setup file importsnitro/appin every file. - Main process. About 130 ms to import the plugin and create the Nitro instance under both runners. After GC, Nitro keeps only 10–16 MB more live heap; the rest of the peak is temporary or native memory.
- Rstest compile. Every route is compiled up front, so Rstest's time and memory grow with the number of routes: 5 → 150 routes moved 1434 → 1866 ms and 359 → 480 MB in the main process. Vitest barely changes. Rspack uses about 76 MB more native memory during the compile, not yet explained.
- Not causes: the Nitro runtime is not duplicated per test file (Rstest already shares it across files). Rstest's higher total memory is mostly Rstest itself: bare, it is already about 120 MB above Vitest.
- Global setup. Rstest builds Node
globalSetupin the same compile, so there is no second Nitro instance there. Browser projects that useglobalSetupget a separate build where Nitro would start again (found by reading Rstest's code, not run).
These numbers come from one machine. The "all processes" totals count memory shared between processes more than once.
Next steps
- Don't load the app in test files that never use Nitro:
serverFetchloads it on first use. Plugins must still load aftervi.mock/rs.mock, anduseNitroApp()must stay synchronous. - Docs: say that the cost grows with the number of test files, and that
isolate: falsehelps large suites (on Rstest, 40 files: 1497 → 1021 ms). - Drop the unused
renderChunkhook of the externals plugin when tracing is off (saves 14–21 ms per Rspack compile). - Load oxc lazily in the
route-metaandimport-attributesplugins (about 10 ms and 12 MB). The Cloudflare output plugin currently depends on oxc already being loaded. - Rstest: skip Nitro in the browser global-setup build, if Rstest can tell that build apart.
Investigated with AI assistance.
- 主要言語
- TypeScript
- スター
- 11.5k
- フォーク
- 968
- 平均マージ
- 4日 9時間
- マージ済み PR(30日)
- 64
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nitrojs/nitro のほかの issue
-
pending triage
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
メンテナーはふだん 2 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
メンテナーはふだん 2 日以内に返信
-
cloudflare: `nitro deploy` fails when a parent directory has a Wrangler config対応中かも @draarivpatel-ui が 13 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
メンテナーはふだん 2 日以内に返信
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 2 日以内に返信
-
pending triage
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
nitrojs/nitro#5205 · リアクション 1 件 ·
メンテナーはふだん 2 日以内に返信
似ている issue
-
bug data-types
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
ClickHouse/clickhouse-js#1293 ·
メンテナーはふだん 1 日以内に返信
-
area: middleware enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
agent/quality testing
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 92/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
juspay/agent-distro#203 ·
メンテナーはふだん 1 日以内に返信