Skip to content

perf(gateway): skip suppressed ambient channel discovery - #184078

Merged
steipete merged 2 commits into
mainfrom
steipete/perf-gateway-startup-readyz-20261026
Oct 26, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/perf-gateway-startup-readyz-20261026

Conversation

@steipete

@steipete steipete commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Gateway startup prepares bundled-channel catalogs, external-channel environment metadata, and prefix tables even when ambient channel credentials are suppressed. Those results are discarded by the existing suppression branch.

User Impact

A small startup allocation/CPU reduction with identical readiness and channel-presence semantics. Explicit configuration and persisted credentials remain available; ambient credentials are still suppressed unless explicitly enabled. No new configuration, cache, schema, or readiness deferral.

Why This Change Was Made

Move the environment-only preparation inside its existing allowed-ambient branch. Production LOC delta is 0 (13 lines relocated); there is no extra mechanism. Startup profiling shows module/filesystem loading and plugin runtime preparation dominate; this PR removes only the bounded redundant channel-discovery work.

The benchmark's opt-in heap profiler now samples collected objects before Gateway entry imports and stops on the first successful external /readyz response plus IPC delivery. Timing runs remain unprofiled. The existing synthetic startup fixture is increased to 10,000 sessions, eight agents, and 44 plugins.

Evidence

Acceptance before comparison: preserve outputs, prove zero catalog work with ambient suppression, reduce owner CPU/allocation, and retain readiness behavior. The startup-only deletion uses focused startup measurements rather than a steady-state stress campaign.

Owner workload: 40 synthetic plugins and 40 configured channels; 250 warmups, 5,000 measured calls per arm per pair, AB/BA order; separate untraced timing and collected-object allocation sampling (4 KiB interval), Node 26.12.1 on macOS.

Owner metric Base Candidate Change
Main-thread CPU, µs/call 47.0072 6.4946 −86.2%
Sampled allocation, bytes/call 104,426.876 19,314.314 −81.5%
GC total, ms/5,000 calls (paired mean) 5.851 4.029 −1.822 ms
Collections per pair 15, 15 3, 3 −80%
Max pause per pair, ms 5.061, 0.613 6.572, 0.419 context, too few samples for tails

Both pairs agree on CPU and allocation direction. Output checksums match. Timing host load was high; CPU uses process.threadCpuUsage, not wall-time scheduling delay. Reproduction: node --expose-gc --import ./scripts/tsx.mjs scripts/perf/channel-presence-suppression.ts --iterations 5000 --mode timing and repeat with --mode allocation on each revision.

The work-count regression fails on base: both sync and async suppressed discovery still call the channel catalog. It verifies explicit config and persisted-auth signals as well as zero catalog/environment metadata reads after the fix.

Startup baseline: ab3425a265a8d3e78b7d47f00d3b4ce5059f1329. Separate diagnostic CPU/heap passes reach readiness on synthetic state. The CPU profile's largest main-thread samples are filesystem open/stat/read, plugin generation path handling, module compilation, and GC; channel-presence discovery is approximately 6 ms inclusive. Collected allocation sampling attributes about 1.35 MiB to channel-presence work out of 3,764.97 MiB total. These diagnostic runs are not latency comparisons.

Focused proof: all 73 tests across src/channels/config-presence.test.ts, src/gateway/server-startup-config.ambient-channels.test.ts, src/gateway/server-startup-log.test.ts, and test/scripts/bench-gateway-startup.test.ts pass. Total wrapper wall time 287 s (cold compilation dominated); channel tests took 17.71 s wall / ~3.2 s test time, startup benchmark tests 208 s wall / 34.9 s test time (existing subprocess coverage). The added profiler case is a small real Node subprocess. The export-name collision guard and both eager-import/PR-wrapper source closure files pass (22 tests, 50.38 s wrapper wall).

Independent subagent review (autoreview route unavailable): clean at P2. The configured autoreview provider selector was rejected before inference; operator configuration was not changed.

Setup issues excluded from measurements: the first saved-build launch lacked packaged root launcher modules, corrected before any valid startup sample; a test fixture needed to retain its IPC channel; one test compilation was rejected because source changed during compilation, then rerun with frozen inputs. The stable-input focused run is green.

Both built sourcePerformance artifacts, changed-file lint, formatting, and pnpm tsgo:scripts pass. The initial tooling typecheck caught the IPC overload nullability and lint caught a shadowed callback name; both are corrected and the incremental review is clean.

Synthetic Gateway startup

Five serial alternating launches per arm, same retained synthetic fixture, fixed built artifacts; no profiler on timing runs. Both arms had separate diagnostic starts first, so these are warmed retained-state starts, not cold-disk or first-install timings. Every /healthz, /readyz, and seeded sessions.list probe succeeded; all shutdowns were graceful.

Metric, median (min–max), n=5 per arm Base Candidate
Ready latency, s 24.514 (23.192–35.709) 26.844 (23.091–32.804)
Process-tree CPU, s 37.510 (36.850–48.440) 40.310 (35.820–46.230)
Observed max RSS, MiB 6146.703 (6142.719–6212.031) 6203.156 (6064.609–6232.641)
Startup trace heap, MiB 333.600 (243.500–339.400) 338.400 (336.100–339.800)

The readiness median rose 9.5%, but the signed paired mean was +0.207 s (+0.77%), with mixed signs and wide overlapping ranges; aggregate process-tree CPU mean changed by −0.58%. This does not demonstrate a startup wall-time improvement or establish a material regression. The isolated owner saving is the supported performance claim. No adverse claim is made from these noisy low-count startup timings, and no tail percentile is used as a gate. The trace heap is an internal startup mark, not a forced-GC retained-heap measurement.

Pair Base ready, s Candidate ready, s Host load base, start→end Host load candidate, start→end
1 24.514 24.529 25.18→21.85 21.85→18.80
2 23.192 23.091 18.80→17.44 17.44→17.92
3 27.333 28.045 17.92→23.06 23.06→25.84
4 23.531 26.844 25.84→22.62 22.62→22.68
5 35.709 32.804 22.68→23.89 23.89→28.36

Median critical-path phase spans (overlap/nesting means they must not be summed): model-runtime preparation 7.493→7.954 s; post-bind plugin loading 6.656→7.286 s; process bootstrap 4.303→5.480 s; session admission 0.823→0.898 s; session projection 0.800→0.812 s. The plugin-loading and database-admission owners remain unchanged.

Startup reproduction: pnpm build sourcePerformance, preserve each revision's packaged root modules and dist with the same dependency installation; seed with node --import ./scripts/tsx.mjs scripts/bench-gateway-startup.ts --case teamBoot --fixture-root <synthetic-root> --seed-only; alternate each built --entry <revision>/dist/entry.js with --runs 1 --warmup 0 --timeout-ms 180000 --output <report.json>. Separate diagnostic runs add either --cpu-prof-dir <dir> or --heap-prof-dir <dir>. CPU ranking uses the main-thread profile prefix through external readiness. Profiles are diagnostic, not a substitute for the unprofiled comparison.

Runtime production LOC is +13/−13 (net 0). Non-test/non-doc delta including tooling is +261: the additional code is the requested reproducible owner benchmark and start-to-readiness allocation capture, not new Gateway machinery.

Limitations: synthetic metadata plugins and sessions, no real-provider/channel turns, no live production traffic, and no 10-minute steady-state stress campaign under the startup-only fast-path exception. These measurements do not establish production deploy downtime savings. Baseline build is the SHA above; candidate measurements use that baseline plus the reviewed runtime hunk, before the required publication rebase. Exact-head CI is reported separately.

Publication rebase onto 7e15500187cd1430cf954ad43e2fd4fb89ac1dd2 preserved both reviewed patches (git range-diff identical). Exact PR head: 23e0de8df1f1ba93aa4a591d30f81135d32692f5. Exact-head CI: green — CI run 40257379167 and security/dependency gate. Final live check read: 62 passed, 58 skipped, none pending or failed. GitHub Codex code review completed on this exact head with no findings. The PR remains ready and unmerged for maintainer handoff.

The first CI run caught two tooling-only issues: the profiler listener returned a Promise to a void event callback, and a test asserted a heap-profile field absent from Node’s declared type. The repair uses a synchronous listener and retains the stronger named-allocation checks while removing the redundant field assertion. Focused lint, the affected root-script test-type check, and all 45 startup-benchmark tests pass after repair. Independent incremental review is clean at P2. All other selected jobs in the first CI run passed; no rerun was used to chase green.

@clawsweeper

clawsweeper Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review October 26, 2026 01:52
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T02:07:34.083288Z 23e0de8 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: M labels Oct 26, 2026
Avoid catalog and environment-prefix preparation when ambient channel credentials are suppressed. Explicit channel configuration and persisted credential discovery remain independent, with unchanged readiness gates. Add a work-count regression and collected-allocation startup profiling through the external readiness boundary.
@steipete
steipete force-pushed the steipete/perf-gateway-startup-readyz-20261026 branch from 93eecd7 to 23e0de8 Compare October 26, 2026 02:05
@steipete
steipete merged commit e6c20d5 into main Oct 26, 2026
138 of 139 checks passed
@steipete
steipete deleted the steipete/perf-gateway-startup-readyz-20261026 branch October 26, 2026 02:20
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 26, 2026
…4078)

* perf(gateway): skip suppressed ambient channel discovery

Avoid catalog and environment-prefix preparation when ambient channel credentials are suppressed. Explicit channel configuration and persisted credential discovery remain independent, with unchanged readiness gates. Add a work-count regression and collected-allocation startup profiling through the external readiness boundary.

* test(gateway): fix startup profiler check contracts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scripts Repository scripts size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant