[PR #1996] [MERGED] perf(cli): bundle runtime entries to reduce Windows startup I/O #4957

Closed
opened 2026-10-31 00:57:22 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1996
Author: @N0zoM1z0
Created: 10/11/2026
Status: ✅ Merged
Merged: 10/12/2026
Merged by: @N0zoM1z0

Base: main ← Head: perf/cli-startup-1685-20261012


📝 Commits (3)

  • f8a6cda perf(cli): bundle runtime entries to reduce Windows startup I/O
  • 2f25b23 fix(build): preserve shared release metadata in runtime bundles
  • c992f1f chore: merge main into CLI startup performance work

📊 Changes

13 files changed (+243 additions, -139 deletions)

View changed files

📝 package.json (+2 -2)
➖ scripts/bundle-mcp-runtime.d.mts (+0 -1)
➖ scripts/bundle-mcp-runtime.mjs (+0 -104)
➕ scripts/bundle-runtime.d.mts (+1 -0)
➕ scripts/bundle-runtime.mjs (+140 -0)
📝 scripts/prepack.mjs (+4 -0)
📝 scripts/rea.mjs (+11 -6)
📝 tests/boundary/cli/cliStartupImports.test.ts (+3 -1)
📝 tests/boundary/cli/dispatcher.test.ts (+5 -5)
📝 tests/boundary/cli/javascriptApplicationJsonOutput.test.ts (+17 -3)
📝 tests/boundary/process/runtimeBundle.test.ts (+55 -15)
📝 tests/fixtures/browserScenarioCancellation.mjs (+4 -1)
📝 turbo.json (+1 -1)

📄 Description

The Windows dispatcher still loads the CLI module graph file by file. Bundle the CLI, output helpers and MCP doctor separately from MCP, while preserving original module URLs, lazy imports and worker files. Keep release metadata in its shared owning module so CLI, MCP, workers and package updates read the same version. Lazy CLI facades retain their source scope and named exports.

On Windows x64 / Node 24.18, two unprofiled observations per input on the same 89f5e489 source gave:

Public CLI input Original Bundled
24.6 KB native Evidence 17.98–19.50 s 6.80–12.02 s
16.17 MB native Evidence 19.32–20.78 s 13.11–13.13 s

Each call used a fresh Node process, shared locked dependencies, two CPUs and BelowNormal priority. Order was counterbalanced; OS caches and host activity were uncontrolled. Separate CPU profiles analyzed with Flameox show module-stat/lstat sample share moving from 70.2% to 54.0%. All self sample weights were checked against raw V8 data; the candidate's inclusive table remains partial at the provider cap.

The package grows by about 1.12 MB compressed because original worker files remain shipped. The JSON/JSONL regression test now uses the documented comma slice and asserts a nonempty projection independently.

Validation at c992f1f7 (main e19879328): build, 18 focused tests, typecheck/lint, docs and normal packaging pass. All 1,392 archive files match source and the fresh Windows installation. Native Windows Evidence views, real JavaScript workers, nonempty filtered JSONL, MCP doctor and default-timeout stdio MCP pass; all 172 tools have valid schemas, text/structured parity and a working following ping. These archive installs reuse existing locked production dependencies. The installed-package verifier also passes, including real npm update through a local release registry, setup/uninstall and cleanup. All 31 exact-head CI checks pass, including the Linux, macOS and Windows package baselines.

Refs #1065, #1685.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/1996 **Author:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Created:** 10/11/2026 **Status:** ✅ Merged **Merged:** 10/12/2026 **Merged by:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Base:** `main` ← **Head:** `perf/cli-startup-1685-20261012` --- ### 📝 Commits (3) - [`f8a6cda`](https://github.com/morluto/rea/commit/f8a6cda8313bedaa713e33801eb9be2791de1561) perf(cli): bundle runtime entries to reduce Windows startup I/O - [`2f25b23`](https://github.com/morluto/rea/commit/2f25b233454cd9520409432b894b41762d2e552f) fix(build): preserve shared release metadata in runtime bundles - [`c992f1f`](https://github.com/morluto/rea/commit/c992f1f74d81c94c077954548962a5e3ad46bab9) chore: merge main into CLI startup performance work ### 📊 Changes **13 files changed** (+243 additions, -139 deletions) <details> <summary>View changed files</summary> 📝 `package.json` (+2 -2) ➖ `scripts/bundle-mcp-runtime.d.mts` (+0 -1) ➖ `scripts/bundle-mcp-runtime.mjs` (+0 -104) ➕ `scripts/bundle-runtime.d.mts` (+1 -0) ➕ `scripts/bundle-runtime.mjs` (+140 -0) 📝 `scripts/prepack.mjs` (+4 -0) 📝 `scripts/rea.mjs` (+11 -6) 📝 `tests/boundary/cli/cliStartupImports.test.ts` (+3 -1) 📝 `tests/boundary/cli/dispatcher.test.ts` (+5 -5) 📝 `tests/boundary/cli/javascriptApplicationJsonOutput.test.ts` (+17 -3) 📝 `tests/boundary/process/runtimeBundle.test.ts` (+55 -15) 📝 `tests/fixtures/browserScenarioCancellation.mjs` (+4 -1) 📝 `turbo.json` (+1 -1) </details> ### 📄 Description The Windows dispatcher still loads the CLI module graph file by file. Bundle the CLI, output helpers and MCP doctor separately from MCP, while preserving original module URLs, lazy imports and worker files. Keep release metadata in its shared owning module so CLI, MCP, workers and package updates read the same version. Lazy CLI facades retain their source scope and named exports. On Windows x64 / Node 24.18, two unprofiled observations per input on the same `89f5e489` source gave: | Public CLI input | Original | Bundled | | --- | --- | --- | | 24.6 KB native Evidence | 17.98–19.50 s | 6.80–12.02 s | | 16.17 MB native Evidence | 19.32–20.78 s | 13.11–13.13 s | Each call used a fresh Node process, shared locked dependencies, two CPUs and BelowNormal priority. Order was counterbalanced; OS caches and host activity were uncontrolled. Separate CPU profiles analyzed with Flameox show module-stat/lstat sample share moving from 70.2% to 54.0%. All self sample weights were checked against raw V8 data; the candidate's inclusive table remains partial at the provider cap. The package grows by about 1.12 MB compressed because original worker files remain shipped. The JSON/JSONL regression test now uses the documented comma slice and asserts a nonempty projection independently. Validation at `c992f1f7` (main `e19879328`): build, 18 focused tests, typecheck/lint, docs and normal packaging pass. All 1,392 archive files match source and the fresh Windows installation. Native Windows Evidence views, real JavaScript workers, nonempty filtered JSONL, MCP doctor and default-timeout stdio MCP pass; all 172 tools have valid schemas, text/structured parity and a working following ping. These archive installs reuse existing locked production dependencies. The installed-package verifier also passes, including real npm update through a local release registry, setup/uninstall and cleanup. All 31 exact-head CI checks pass, including the Linux, macOS and Windows package baselines. Refs #1065, #1685. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 00:57:22 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#4957
No description provided.