Repository navigation
fix(gateway): reduce fleet bootstrap inspection overhead - #150444
Conversation
|
🦞👀 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. |
|
Codex review: blocked before merge. Reviewed September 17, 2026, 12:03 AM ET / 04:03 UTC (Revision 4). ClawSweeper reviewWhat this changesReuse two database-inspection processes across fleet startup checks and expand startup logs with bootstrap timings and fleet counts. Merge readiness⛔ Blocked before merge - 1 item remains This remains a useful, scoped performance fix that current main does not provide. No blocking correctness or security findings remain; the documented maintainer disposition resolves the previous upgrade-proof request without claiming upgrade success. Priority: P1 Review scores
Verification
How this fits togetherBefore the Gateway serves requests, database preflight checks configured agents for schema compatibility, integrity, and ownership. Its results either permit startup, isolate an incompatible secondary agent, or report a blocking failure. flowchart TD
A[Configuration and agent inventory] --> B[Database preflight]
B --> C[Two reusable inspection processes]
C --> D[Fresh direct read or private snapshot]
D --> E[Integrity and ownership checks]
E --> F[Startup admission or refusal]
B --> G[Bootstrap timing logs]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +342, Tests +220, Docs 0. Total +562 across 17 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep admission checks fresh and artifact-preserving while amortizing reader setup within each bounded fleet pass; retain broader startup recovery in the existing fleet issues. Do we have a high-confidence way to reproduce the issue? Yes: current main starts one schema-reader process per inspection, and the supplied fleet measurements demonstrate the resulting admission cost. This read-only review did not execute a reproduction. Is this the best way to solve the issue? Yes: reusing the existing two scheduler slots removes repeated setup while retaining fresh inspection and established admission owners; no competing implementation or new configuration surface is needed. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c0cac4286a62. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
1d1bed1 to
077abba
Compare
Reuse the two preflight readers across each fleet pass while preserving fresh integrity and ownership checks. Starting a process for every database repeated module loading and canonical schema setup during bootstrap. Route private snapshot integrity and schema checks through the same readers on clean restarts, retaining snapshot ownership and native-close cleanup. Extend the existing startup trace with bootstrap substeps, process-relative starts, fleet counts, and the breakdown at readiness. Reported by @609NFT in #148529. Related: #149538.
077abba to
cb599c7
Compare
|
Merged via squash.
|
Retain unfinished agent inspections under the Gateway lifetime instead of turning a foreground timeout into a fatal startup error. Keep the agent degraded until inspection and guarded credential, session, and model preparation complete; cancel and join that work during shutdown. Preserve caller cancellation, propagate failures until background handoff, and keep inherited auth snapshots within their selected state directory. Thanks to @desksk for the report and offline integrity timings. Refs #150574, #141918, #142179, #150444.
Retain unfinished agent inspections under the Gateway lifetime instead of turning a foreground timeout into a fatal startup error. Keep the agent degraded until inspection and guarded credential, session, and model preparation complete; cancel and join that work during shutdown. Preserve caller cancellation, propagate failures until background handoff, and keep inherited auth snapshots within their selected state directory. Thanks to @desksk for the report and offline integrity timings. Refs #150574, #141918, #142179, #150444.
Retain unfinished agent database inspections under the Gateway lifetime so a slow healthy database no longer turns its foreground wait timeout into a fatal startup error. Keep affected agents degraded until inspection and guarded credential, session, and model preparation complete; healthy agents can serve in the meantime. Corruption and pending migrations retain Doctor guidance. Compose deferred admission with the existing Linux spawn-broker owner. Shutdown cancels and joins retained inspection and preparation before broker cleanup. Preserve caller cancellation, foreground failures before handoff, and inherited auth snapshots within their selected state directory. Thanks to @desksk for the report and offline integrity timings. Validation: recorded focused and real SQLite-child/HTTP boundary proof, scoped-clean Codex review, and green exact-head CI. Published-updater and retained Windows-service compatibility remain unverified; the PR records the scoped Rank-up skip. Closes #150574. Related: #141918, #142179, #150444, #150564.
) Fleet database admission repeatedly started a schema-inspection process for every agent after openclaw#147635 enabled the heavier reader during Gateway startup. Reuse one reader in each of the existing two scheduler slots while preserving fresh reads, integrity and ownership checks, private-snapshot recovery, cancellation, and joined cleanup. Bootstrap tracing now records substeps, durations, repeated calls, and fleet counts. In the isolated 200-agent repeat boots, schema readers fall from 200 to two and database admission falls from 44.38s to 15.93s and 8.11s. Whole-startup timings remain variable; these measurements do not establish installed-updater compatibility or the reporter's 632-agent readiness target. No schema, configuration, backup, or rollback contract changes. Related: openclaw#148529, openclaw#149538. Thanks to @609NFT for the per-build fleet measurements and repeat-boot target. Validation: 41 focused tests, changed-file checks, build, scoped-clean Codex review, and isolated Gateway boots reaching readiness and exiting cleanly. Exact-head CI run 35177837447 is green for cb599c7. The published-driver upgrade proof and 632-agent whole-startup target remain explicit proof gaps under the maintainer disposition in the PR body.
…150755) Retain unfinished agent database inspections under the Gateway lifetime so a slow healthy database no longer turns its foreground wait timeout into a fatal startup error. Keep affected agents degraded until inspection and guarded credential, session, and model preparation complete; healthy agents can serve in the meantime. Corruption and pending migrations retain Doctor guidance. Compose deferred admission with the existing Linux spawn-broker owner. Shutdown cancels and joins retained inspection and preparation before broker cleanup. Preserve caller cancellation, foreground failures before handoff, and inherited auth snapshots within their selected state directory. Thanks to @desksk for the report and offline integrity timings. Validation: recorded focused and real SQLite-child/HTTP boundary proof, scoped-clean Codex review, and green exact-head CI. Published-updater and retained Windows-service compatibility remain unverified; the PR records the scoped Rank-up skip. Closes openclaw#150574. Related: openclaw#141918, openclaw#142179, openclaw#150444, openclaw#150564.
Related: #148529, #149538
What Problem This Solves
Gateway restarts on large agent fleets spend much of bootstrap repeatedly starting schema-inspection processes, while the existing aggregate trace hides that work.
User Impact
The 200-agent repeat boots' database admission falls from 44.38s to 15.93s and 8.11s, using two schema readers instead of 200. Warm bootstrap measured 101.84s and 39.06s against the earlier 69.63s baseline: one run was slower, so this does not establish a reliable whole-startup speedup on the shared host. The existing startup trace now names earlier CLI/import/config/admission steps, their process-relative starts, durations, repeated-call counts, and fleet counts;
process.bootstrapandreadycarry the breakdown.Why This Change Was Made
The published-package comparison and parent-relative source inspection identify #147635 (
3cfc0ade66c68092051ec372632bf6d71611e8e2) as the landing that enabled the heavier one-shot schema reader from #143802 during Gateway startup. Every database then reloads that reader's modules and rebuilds its process-local canonical schema contract. The existing two scheduler slots now retain one reader each for a pass. Each request acquires a fresh source handle and read transaction; integrity, ownership checks, typed failures, and private-snapshot recovery remain with their existing owners. For clean restarts, the same readers inspect parent-owned private snapshots, removing the separate per-agent integrity child and duplicate parent-side schema validation. Snapshot preparation retains its artifact-preserving owner, and file-identity checks run around native inspection. Both reader processes are joined before the pass settles. Configured agent membership is also prepared once for the pass.This preserves the direct-read benefit of #147635 while removing repeated setup. The inspected #149963, #149964, #150016, and #150004 campaign changes did not introduce this per-agent schema-child path. Intermediate commits were inspected rather than individually timed. It does not attribute the entire historical bootstrap regression to that landing: config-snapshot time also grew from 6.02s on the published repeat boot to 14.40s on the main baseline. The new trace keeps that separate cost visible.
The optimization runs inside the existing candidate-side Gateway startup path and requires no new update-driver marker or option. It changes no schema, configuration, migration, backup, or rollback contract. The published 9.4 arm here is a boot comparison; an installed-updater end-to-end run was not performed. The reusable child explicitly owns IPC shutdown because a direct Node 26 probe reproduced
exitwithoutcloseafter parent-initiated disconnect. Cancellation and native-close failure tests preserve the join and source-lease contracts.Production LOC: +621/−279 (net +342). Test LOC: +243/−23 (net +220). The added production code supplies the bounded bootstrap breakdown and the reusable reader's request, cancellation, and close lifecycle; the one-shot reader entry point is removed.
Evidence
Thanks to @609NFT for the per-build fleet measurements and the concrete repeat-boot target in the report.
Isolated 200-agent measurements
Node 24.21.0 on macOS, 200 workspaces/databases, 54 configured models per agent, the same 12 enabled bundled plugins, no channels, loopback, and a 2560 MiB heap cap. Main baseline:
b5eb58956fa1557eb2ddd456dfe405c2878590fc. Candidate:1d1bed152b37caf309e8285ab192a4af61a48cae. Durations below are seconds and use the startup trace; nested spans overlap and must not be summed.The main before/after pairs start from the same saved copy of the L470 schema-21 fixture. Published 2026.9.4 supports agent schema 19, so its equivalent empty agent stores were created by the published package's own schema owners with the same configuration and workspace topology. The first published boot includes 56.10s of plugin convergence and 59.95s of legacy migration; the repeat boot is the useful regression comparison. Its bootstrap is 46.47s versus main's 69.63s. Older bootstrap substeps marked
—are uninstrumented, not zero.The host is shared, and the slower candidate run is retained above. Config validation took 56.51s on the second candidate boot and 13.66s on the unchanged third boot; CPU time during the third validation was 13.51s. The config file predates both runs. Early entry imports also rose from 68.5ms on baseline to 912.4ms on the slow candidate, before database admission. Source inspection rules out the suspected agent-sidecar cost shift: both old and new closed-WAL snapshot routes preserve absent sidecars, while config validation reads shared plugin state rather than agent stores. The first candidate had zero snapshot fallbacks yet also showed longer validation. These results support the reader-process reduction and expose substantial timing variation; they do not explain every later-phase change. Published 9.4 required the harness's bounded SIGKILL cleanup after readiness; its background memory cleanup reported cancellation after the requested stop. The 632-agent reporter's under-660s readiness target still requires a real-fleet run. The process-count regression is covered at the real preflight boundary; the broader startup and post-ready issues remain open.
Validation
expected two forks, got three. A second closed-WAL regression failed the initial partial fix withexpected two schema/integrity forks, got five; both now pass with two schema readers and three completed inspections. Snapshot-copy subprocesses are separate and are not counted as schema readers.node scripts/check-changed.mjsandpnpm buildpass. The failed-close proof awaits observed snapshot cleanup while its peer remains paused, and verifies both readers join before settlement.origin/main.Reporter's 632-agent table (reported observations)
process.bootstrapstate.schema-preflightstartup.maintenancesidecars.model-runtimeruntime.post-attach1611ca6d1611ca6de252366f(#149600, #149716)e252366fe252366f9780b62abf75b2669(#150188, #150004)Maintainer disposition of ClawSweeper feedback
Reviewed the ClawSweeper review for exact head
cb599c707e7283ec8398073d1fe490d29aea0786. It identifies no actionable patch or security finding.cb599c707e7283ec8398073d1fe490d29aea0786; the native watcher reportsrollup=green,github_rollup=SUCCESS, andpending=0. No rerun was requested.