Skip to content

improve(gateway): overlap macOS system-CA warmup with startup - #128422

Merged
steipete merged 1 commit into
mainfrom
perf/overlap-system-ca-warmup
Aug 24, 2026
Merged

steipete merged 1 commit into
mainfrom
perf/overlap-system-ca-warmup

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where a macOS Gateway could spend up to 4972ms of a first boot after the OS trust cache went cold waiting for the default system CA set on the readiness critical path. The same lookup measured 3529ms in a fresh standalone Node process, while subsequent Gateway boots measured 16-160ms.

Why This Change Was Made

The Gateway now starts one process-wide system-CA warmup immediately after kernel creation, allowing the Keychain read to overlap the remaining bootstrap and attach work. The existing post-attach barrier awaits that same retained promise before plugins or worker providers can use TLS; warmup failures remain fail-open and are not retried because this is only an optimization. Minimal test gateways remain unchanged. No config or changelog surface is added.

User Impact

Cold macOS Gateway starts can overlap the expensive trust-cache read with other startup work instead of paying the full delay serially before readiness. Warm starts and non-macOS platforms retain their existing behavior.

Evidence

  • Pre-fix regression: the new owner-boundary tests failed in both Gateway Vitest configurations because the single-flight entry point was absent.
  • node scripts/run-vitest.mjs src/gateway/system-ca-warmup.test.ts — 16 tests passed across 2 configurations.
  • node scripts/run-vitest.mjs src/gateway/server-import-boundary.test.ts — 16 tests passed across 2 configurations.
  • node scripts/run-vitest.mjs src/gateway/server-startup-post-attach.test.ts — 168 tests passed across 2 configurations; the injected barrier still completes before worker reconciliation and sidecars.
  • node scripts/check-changed.mjs — Blacksmith Testbox sync timed out before the checks ran (exit 124); the authorized local fallback completed all selected core and core-test gates successfully.
  • pnpm build — passed.
  • Built isolated Gateway using the sanitized copied state on port 19791 reached /readyz; residual barrier trace: startup trace: post-attach.system-ca 0.5ms total=1456.6ms eventLoopMax=0.0ms.
  • .claude/skills/autoreview/scripts/autoreview --mode branch --base origin/main — clean, no accepted/actionable findings.
  • Production LOC: +21/-2 (net +19); tests: +32/-0. The production growth is the lifecycle-owned single-flight entry point, its early kickoff, and the existing dependency barrier retarget; no parallel warmup path or compatibility layer was added.

Measured on this machine, the first boot after the OS trust cache went cold spent 4972ms in post-attach.system-ca; a fresh standalone Node process took 3529ms, while subsequent boots took 16-160ms. Start the single-flight warmup after kernel creation so the existing post-attach barrier observes only the residual wait.
@clawsweeper

clawsweeper Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Aug 24, 2026
@steipete
steipete marked this pull request as ready for review August 24, 2026 00:19
@steipete

Copy link
Copy Markdown
Contributor Author

ClawSweeper Rank-up moves: none published for the current head. The latest live comment remains the review started placeholder for f6d7ea22ff6a13058baf901bcd31a3ec312cef48, so there are no moves to apply or skip individually. Exact-head CI, autoreview, live startup proof, and the native review artifacts are green; proceeding under the repository rule that a queued or late review publisher does not block landing.

@steipete
steipete merged commit b0d6fff into main Aug 24, 2026
294 checks passed
@steipete
steipete deleted the perf/overlap-system-ca-warmup branch August 24, 2026 00:36
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 24, 2026
…w#128422)

Measured on this machine, the first boot after the OS trust cache went cold spent 4972ms in post-attach.system-ca; a fresh standalone Node process took 3529ms, while subsequent boots took 16-160ms. Start the single-flight warmup after kernel creation so the existing post-attach barrier observes only the residual wait.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant