Repository navigation
perf(gateway): shorten startup handoff and defer receipt persistence - #174159
Merged
Merged
Conversation
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
steipete
marked this pull request as ready for review
October 16, 2026 11:20
Contributor
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 17, 2026
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.
What Problem This Solves
Gateway ownership acquisition can remain asleep after a predecessor releases its lock, and plugin startup waits for advisory native-source receipt persistence after admission has completed.
User Impact
Ordinary ownership contention is checked every 250 ms instead of backing off to two seconds. Admitted plugins can finish startup while receipt persistence continues under the existing cache owner. Overall measured cold-start and stop/start time are neutral; this is a smaller critical path, not a claimed whole-startup speedup.
The five-minute acquisition deadline, single-instance checks, unknown-namespace heartbeat wait, config/auth validation, and recovery ordering remain unchanged. No configuration, schema, or upgrade migration is required.
Why This Change Was Made
Remove the extra backoff cap and the startup-only persistence join. Failed physical-lock probes stop before worker creation or SQLite reads; the tradeoff is at most four ordinary contention probes per second. Native bytes are already admitted, model workers receive the in-memory receipt overlay, and cache retirement still joins accepted writes before releasing captures.
Production LOC: 8 deleted, 0 added. The uncontended lock path still performs lease inspection/publication and heartbeat initialization; it has no fixed sleep. Environment selection still loads dotenv, validates/selects config, and pins state paths. Its later reread protects changed configuration/credentials after proxy teardown. Plugin registration remains serial with event-loop yields. Subagent recovery is unchanged.
Evidence
Local proof: 65 tests passed across
src/infra/gateway-lock.test.ts,src/infra/gateway-lock.namespace.test.ts, andsrc/gateway/server-startup-plugins.test.ts, usingpnpm test <those files> --maxWorkers=1. Total wrapper wall time: 65.03 s, including native worker preparation; Gateway file wall time 44.71 s, two infra files 7.22 s. The handoff regression took 124 ms and native receipt regression 983 ms. Changed-file formatting, scoped core lint, andgit diff --checkpassed. Independent Codex review is scoped-clean at P0–P2, with no actionable findings.Both regressions fail on original code: prolonged handoff exceeds the 250 ms bound (749 ms simulated lag), and plugin startup remains blocked behind the actual receipt publisher. The plugin regression also proves cache retirement waits for publication and reads the saved receipt afterward.
Measurement: isolated Linux/Node 26.8.1, three baseline pairs followed by three candidate pairs. Each pair restores the same maintained synthetic fixture: 5,000 sessions, 6,000 retained runs, 200 approvals, 100 disabled cron jobs, 12 project worktrees, a 4.64 GB agent database, and one installed no-network native-artifact plugin. Optional memory indexing is disabled equally in both arms. These are fresh-process starts, without purging OS page caches. Baseline
594e35ed589d1441bc3d4d1304c8aae9bd09a55f; candidate uses the two production-file changes from3cfc7e47b78faad163eaf23be12023c0d9365c9a, with both runtime builds prepared separately./readyz200/readyz200Cold HTTP ranges: 39.491–39.705 s before, 39.251–40.001 s after. Stop-to-ready ranges: 22.112–39.004 s before, 21.530–22.795 s after. The restored cold fixture waits for an approximately 20 s full agent database integrity check (
no-proof); one baseline restart also takes that fallback. Candidate/readyzbodies explicitly transition fromstartup-sidecarstoagent-database:main/agent-database-inspection-pending, then become ready. Event-loop degradation is diagnostic, not the readiness blocker.A fresh CLI successor started while its predecessor is alive is correctly refused at
cli.bootstrap.admission.live-owner, before lock acquisition. The measured deployment sequence therefore uses stop → confirmed exit → fresh successor. Lock contention is a separate real holder/contender-process experiment with a fixed 5,001 ms hold after contention starts: before 757–781 ms, after 26–54 ms. This phase-dependent result is not a CLI deployment speedup claim; ordinary retry sleep is bounded at 250 ms plus probe/acquisition work.Both arms begin with zero native receipts/artifacts/namespaces and finish with one of each. All measured Gateway processes exit successfully. No production state or services were used; benchmark state/processes were removed. No Testbox/Crabbox leases; PR CI owns broad validation.
Per-phase medians (milliseconds; overlapping/nested phases are not additive)
process.bootstrapcli.bootstrap.gateway-lockcli.main.gateway-run-select-environmentcli.main.gateway-run-pre-bootstrapcli.main.gateway-run-bootstrapcli.command.config-readycli.bootstrap.admission.state-snapshotcli.bootstrap.admission.database-readinesscli.bootstrap.admission.plugin-configconfig.authplugins.runtime-post-bindsessions.admissionsidecars.main-session-recoverysidecars.model-runtimesidecars.ready.totalThe single-plugin fixture does not reproduce a large installed-plugin registry or establish a production-wide speedup. Neutral overall timing is the expected limitation of this net-deletion change.
Broad CI: exact-head run 38893093431; the complete selected CI checks and aggregate gate passed on the reviewed head. No CI retries or inherited-failure exception were needed.