Repository navigation
perf(cli): stop respawning the CLI to hide a warning Node no longer emits - #206448
Merged
Merged
Conversation
…mits - The startup respawn added --disable-warning=ExperimentalWarning for node:sqlite (165841a). - node:sqlite has emitted no experimental warning since Node 24.15.0; engines require >=24.16.0. - POSIX CLI commands now run in the first Node process; respawn remains for CA certificates and the Windows stack size.
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
obviyus
added a commit
that referenced
this pull request
Nov 27, 2026
## Problem
Cold time-to-first-request of the one-shot `openclaw agent --local` turn (the path benchmark boards run) has no regression gate. A measured turn on `b0a6e8cd` took 6.05 s median to the first provider request (warm Gateway: 0.69 s). Most of it is fan-out: every Node process and worker thread boots its own module graph before the first request. Nothing stops a change from adding another one.
## Change
Add `src/cli/agent-local-cold-start.process.test.ts`: one real `agent --local` turn from source, run on Node (the default install's runtime, also when Vitest runs on Bun), against the local fake OpenAI Responses server (`test/helpers/openai-responses-model-fixture.ts`). A ledger preload, carried by `NODE_OPTIONS` into every descendant process that inherits the environment and into every worker thread, counts up to the moment the fake provider receives the first request:
- `nodeProcesses`: Node processes that started (CLI, respawns, inheriting children),
- `nodeSpawns`: Node spawn calls from any process or thread (covers children that start with a clean environment),
- `workerThreads`: worker threads constructed in any process or thread.
The test asserts ceilings `{ nodeProcesses: 4, nodeSpawns: 5, workerThreads: 19 }`, measured on the Linux CI runner (macOS starts 18 workers). Counts, not wall time: they do not move with host load. A PR that removes work lowers the budget in the same change.
The fixture keeps the default startup (`OPENCLAW_NO_RESPAWN` unset) and marks host CA discovery done (`OPENCLAW_NODE_EXTRA_CA_CERTS_READY=1`), because that respawn depends on the host's Node install. Windows is skipped: it always respawns for its stack size, so its topology differs by design.
## Evidence
- Red on the merge base before #206448 (`b0a6e8cd`, first version of this test): the warning-only respawn adds a CLI process. Green on main with #206448.
- Counts: Linux CI (Node CLI under the Bun Vitest lane) 4 / 5 / 19; macOS arm64 Node 24.22.1, 3 runs, 4 / 5 / 18 each.
- Review round 1 findings fixed: Windows topology (skipped, documented) and descendant work (ledger now propagates through `NODE_OPTIONS` and counts in every thread; process starts and spawn calls are separate counters).
- Cost: one CLI turn from source, about 16-31 s test time locally (88 s once under host load 40); same 120 s timeout as `agent-local-rpc-cleanup.process.test.ts`. No cheaper layer proves the processes and workers a real turn starts before its first request.
Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 28, 2026
…mits (openclaw#206448) ## Problem Every POSIX CLI call (including the one-shot `openclaw agent --local` turn that benchmark boards run) started Node twice. `buildCliRespawnPlan` re-executed the CLI only to add `--disable-warning=ExperimentalWarning`, a flag added for the `node:sqlite` experimental warning (1cfcc6a, 2026-01-13). `node:sqlite` stopped emitting that warning in Node 24.15.0 (`lib/sqlite.js` has `emitExperimentalWarning` in v24.14.0 and none in v24.15.0, v24.16.0, v26.1.0), and `engines` requires Node `>=24.16.0 <25 || >=26.1.0`. The second Node boot is pure waste. ## Change - Delete the warning-only respawn branch from `src/entry.respawn.ts` and its skip policy `shouldSkipRespawnForArgv` from `src/cli/respawn-policy.ts`. - Respawn stays for the two cases that need a fresh process: auto-discovered `NODE_EXTRA_CA_CERTS` (Linux version-manager Node) and the Windows stack size. - Tests: the respawn tests now assert that common commands run in process unless Node must reload its trust store. Tests that used the warning respawn as a vehicle now use a CA respawn, or run on Windows only (`node-runtime-recovery` startup-respawn cases: POSIX no longer respawns there). ## Evidence Acceptance rule (written before the run): cold `openclaw agent --local` one-shot turn, built `dist`, fresh scratch state per run, real OpenAI `gpt-5.4-nano`; metric = process start to `provider.request.started` (diagnostics timeline) and the CLI entry stage; ABAB with the base build, 8 samples each, same load band. Win = one fewer Node process per CLI call and a lower entry stage, no metric worse. | metric (ABAB n=8, load 15-21) | base 69bb592 | this PR | |---|---|---| | Node processes per CLI call | 2 | 1 | | node boot + entry wrapper, median | 311 ms | 154 ms | | node boot + entry wrapper, p90 | 352 ms | 174 ms | | start -> first provider request, median | 8769 ms | 7440 ms | | start -> first provider request, p90 | 9777 ms | 9640 ms | The total is noisy at this load (shared host); the entry stage drop (-157 ms median) is the attributable part. - No warning: an `OPENCLAW_NO_RESPAWN=1` `agent --local` turn on Node 24.22.1 printed no `ExperimentalWarning`. `node -e "require('module').registerHooks(...); require('node:sqlite')"` prints nothing. - Code Mode's worker passes its own `execArgv` with `--experimental-vm-modules`; explicit worker `execArgv` replaces the parent flags, so its warning was never suppressed by this respawn (checked with a minimal worker on and off the flag). - Tests: `ocx test src/entry.respawn.test.ts src/cli/cli-utils.test.ts src/infra/update-managed-service-handoff-node.test.ts src/process/respawn-child-runner.test.ts src/cli/gateway-backed-exit.process.test.ts test/scripts/node-runtime-recovery.built-cli.e2e.test.ts` and importers (`github-exec-launch`, `run-main.cleanup`, `entry.respawn-diagnostics`) pass locally. ## Diff Production: -58 lines, +3. Tests: net -76 lines. Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 28, 2026
…law#206466) ## Problem Cold time-to-first-request of the one-shot `openclaw agent --local` turn (the path benchmark boards run) has no regression gate. A measured turn on `69bb5929` took 6.05 s median to the first provider request (warm Gateway: 0.69 s). Most of it is fan-out: every Node process and worker thread boots its own module graph before the first request. Nothing stops a change from adding another one. ## Change Add `src/cli/agent-local-cold-start.process.test.ts`: one real `agent --local` turn from source, run on Node (the default install's runtime, also when Vitest runs on Bun), against the local fake OpenAI Responses server (`test/helpers/openai-responses-model-fixture.ts`). A ledger preload, carried by `NODE_OPTIONS` into every descendant process that inherits the environment and into every worker thread, counts up to the moment the fake provider receives the first request: - `nodeProcesses`: Node processes that started (CLI, respawns, inheriting children), - `nodeSpawns`: Node spawn calls from any process or thread (covers children that start with a clean environment), - `workerThreads`: worker threads constructed in any process or thread. The test asserts ceilings `{ nodeProcesses: 4, nodeSpawns: 5, workerThreads: 19 }`, measured on the Linux CI runner (macOS starts 18 workers). Counts, not wall time: they do not move with host load. A PR that removes work lowers the budget in the same change. The fixture keeps the default startup (`OPENCLAW_NO_RESPAWN` unset) and marks host CA discovery done (`OPENCLAW_NODE_EXTRA_CA_CERTS_READY=1`), because that respawn depends on the host's Node install. Windows is skipped: it always respawns for its stack size, so its topology differs by design. ## Evidence - Red on the merge base before openclaw#206448 (`69bb5929`, first version of this test): the warning-only respawn adds a CLI process. Green on main with openclaw#206448. - Counts: Linux CI (Node CLI under the Bun Vitest lane) 4 / 5 / 19; macOS arm64 Node 24.22.1, 3 runs, 4 / 5 / 18 each. - Review round 1 findings fixed: Windows topology (skipped, documented) and descendant work (ledger now propagates through `NODE_OPTIONS` and counts in every thread; process starts and spawn calls are separate counters). - Cost: one CLI turn from source, about 16-31 s test time locally (88 s once under host load 40); same 120 s timeout as `agent-local-rpc-cleanup.process.test.ts`. No cheaper layer proves the processes and workers a real turn starts before its first request. Co-authored-by: Ayaan Zaidi <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every POSIX CLI call (including the one-shot
openclaw agent --localturn that benchmark boards run) started Node twice.buildCliRespawnPlanre-executed the CLI only to add--disable-warning=ExperimentalWarning, a flag added for thenode:sqliteexperimental warning (165841a, 2026-01-13).node:sqlitestopped emitting that warning in Node 24.15.0 (lib/sqlite.jshasemitExperimentalWarningin v24.14.0 and none in v24.15.0, v24.16.0, v26.1.0), andenginesrequires Node>=24.16.0 <25 || >=26.1.0. The second Node boot is pure waste.Change
src/entry.respawn.tsand its skip policyshouldSkipRespawnForArgvfromsrc/cli/respawn-policy.ts.NODE_EXTRA_CA_CERTS(Linux version-manager Node) and the Windows stack size.node-runtime-recoverystartup-respawn cases: POSIX no longer respawns there).Evidence
Acceptance rule (written before the run): cold
openclaw agent --localone-shot turn, builtdist, fresh scratch state per run, real OpenAIgpt-5.4-nano; metric = process start toprovider.request.started(diagnostics timeline) and the CLI entry stage; ABAB with the base build, 8 samples each, same load band. Win = one fewer Node process per CLI call and a lower entry stage, no metric worse.The total is noisy at this load (shared host); the entry stage drop (-157 ms median) is the attributable part.
OPENCLAW_NO_RESPAWN=1agent --localturn on Node 24.22.1 printed noExperimentalWarning.node -e "require('module').registerHooks(...); require('node:sqlite')"prints nothing.execArgvwith--experimental-vm-modules; explicit workerexecArgvreplaces the parent flags, so its warning was never suppressed by this respawn (checked with a minimal worker on and off the flag).ocx test src/entry.respawn.test.ts src/cli/cli-utils.test.ts src/infra/update-managed-service-handoff-node.test.ts src/process/respawn-child-runner.test.ts src/cli/gateway-backed-exit.process.test.ts test/scripts/node-runtime-recovery.built-cli.e2e.test.tsand importers (github-exec-launch,run-main.cleanup,entry.respawn-diagnostics) pass locally.Diff
Production: -58 lines, +3. Tests: net -76 lines.