


























@@ -124,6 +124,94 @@ Checked-in fixture:
124124- Refresh with `pnpm test:startup:bench:update`
125125- Compare current results against the fixture with `pnpm test:startup:bench:check`
126126127+## Gateway startup bench
128+129+Script: [`scripts/bench-gateway-startup.ts`](https://github.com/openclaw/openclaw/blob/main/scripts/bench-gateway-startup.ts)
130+131+The benchmark defaults to the built CLI entry at `dist/entry.js`; run
132+`pnpm build` before using the package-script commands. To measure the source
133+runner instead, pass `--entry scripts/run-node.mjs` and keep those results
134+separate from built-entry baselines.
135+136+Usage:
137+138+- `pnpm test:startup:gateway -- --runs 5 --warmup 1`
139+- `pnpm test:startup:gateway -- --case default --runs 10 --warmup 1`
140+- `pnpm test:startup:gateway -- --case skipChannels --case fiftyPlugins --runs 5`
141+- `node --import tsx scripts/bench-gateway-startup.ts --case default --runs 5 --output .artifacts/gateway-startup.json`
142+- `node --import tsx scripts/bench-gateway-startup.ts --case default --runs 3 --cpu-prof-dir .artifacts/gateway-startup-cpu`
143+144+Case ids:
145+146+- `default`: normal Gateway startup.
147+- `skipChannels`: Gateway startup with channel startup skipped.
148+- `oneInternalHook`: one configured internal hook.
149+- `allInternalHooks`: all internal hooks.
150+- `fiftyPlugins`: 50 manifest plugins.
151+- `fiftyStartupLazyPlugins`: 50 startup-lazy manifest plugins.
152+153+Output includes first process output, `/healthz`, `/readyz`, HTTP listen log time,
154+Gateway ready log time, CPU time, CPU core ratio, max RSS, heap, startup trace
155+metrics, event-loop delay, and plugin lookup-table detail metrics. The script
156+enables `OPENCLAW_GATEWAY_STARTUP_TRACE=1` in the child Gateway environment.
157+158+Read `/healthz` as liveness: the HTTP server can answer. Read `/readyz` as
159+usable readiness: startup plugin sidecars, channels, and ready-critical
160+post-attach work have settled. Gateway startup hooks are dispatched
161+asynchronously and are not part of the readiness guarantee. Ready log time is the
162+Gateway's internal ready log timestamp; it is useful for process-side
163+attribution but is not a substitute for the external `/readyz` probe.
164+165+Use JSON output or `--output` when comparing changes. Use `--cpu-prof-dir` only
166+after the trace output points at import, compile, or CPU-bound work that cannot
167+be explained from phase timings alone. Do not compare source-runner results with
168+built `dist/entry.js` results as the same baseline.
169+170+## Gateway restart bench
171+172+Script: [`scripts/bench-gateway-restart.ts`](https://github.com/openclaw/openclaw/blob/main/scripts/bench-gateway-restart.ts)
173+174+The restart benchmark is supported on macOS and Linux only. It uses SIGUSR1 for
175+in-process restarts and fails immediately on Windows.
176+177+The benchmark defaults to the built CLI entry at `dist/entry.js`; run
178+`pnpm build` before using the package-script commands. To measure the source
179+runner instead, pass `--entry scripts/run-node.mjs` and keep those results
180+separate from built-entry baselines.
181+182+Usage:
183+184+- `pnpm test:restart:gateway -- --case skipChannels --runs 1 --restarts 5`
185+- `pnpm test:restart:gateway -- --case default --runs 3 --restarts 3 --warmup 1`
186+- `pnpm test:restart:gateway -- --case skipChannelsAcpxProbe --case skipChannelsNoAcpxProbe --runs 1 --restarts 5`
187+- `node --import tsx scripts/bench-gateway-restart.ts --case fiftyPlugins --runs 1 --restarts 5 --output .artifacts/gateway-restart.json`
188+- `node --import tsx scripts/bench-gateway-restart.ts --json`
189+190+Case ids:
191+192+- `skipChannels`: restart with channels skipped.
193+- `skipChannelsAcpxProbe`: restart with channels skipped and ACPX startup probe on.
194+- `skipChannelsNoAcpxProbe`: restart with channels skipped and ACPX startup probe off.
195+- `default`: normal restart.
196+- `fiftyPlugins`: restart with 50 manifest plugins.
197+198+Output includes next `/healthz`, next `/readyz`, downtime, restart ready timing,
199+CPU, RSS, startup trace metrics for the replacement process, and restart trace
200+metrics for signal handling, active-work drain, close phases, next start, ready
201+timing, and memory snapshots. The script enables
202+`OPENCLAW_GATEWAY_STARTUP_TRACE=1` and `OPENCLAW_GATEWAY_RESTART_TRACE=1` in the
203+child Gateway environment.
204+205+Use this benchmark when a change touches restart signaling, close handlers,
206+startup-after-restart, sidecar shutdown, service handoff, or readiness after
207+restart. Start with `skipChannels` when isolating Gateway mechanics from channel
208+startup. Use `default` or plugin-heavy cases only after the narrow case explains
209+the restart path.
210+211+Trace metrics are attribution hints, not verdicts. A restart change should be
212+judged from multiple samples, the matching owner span, `/healthz` and `/readyz`
213+behavior, and the user-visible restart contract.
214+127215## Onboarding E2E (Docker)
128216129217Docker is optional; this is only needed for containerized onboarding smoke tests.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。