Skip to content

chore: trace first-run Gateway work and verify later replies - #195185

Merged
steipete merged 4 commits into
mainfrom
solid2/w-perf-first-run-server-1107
Nov 8, 2026
Merged

steipete merged 4 commits into
mainfrom
solid2/w-perf-first-run-server-1107

Conversation

@steipete

@steipete steipete commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Related: #194866, #194914, #194958

What Problem This Solves

The first-run benchmark could not attribute Gateway subprocess costs and stopped after the second reply, leaving later-turn regressions outside its workload.

User Impact

There is no production behavior change. The benchmark now measures a third real reply, can collect opt-in Gateway profiles and executable-only subprocess timing, and keeps the synthetic workspace's Git discovery inside its fixture.

Why This Change Was Made

The first-run investigation traced two different costs: setup detection's native/compiler probes, and cold first-reply admission, session hydration/writing, skills and memory preparation. Independent setup probes and diff-baseline preparation already overlap. Three optimization variants failed the paired-flow guardrails, so every Gateway, session, database and Apple runtime change was removed. This PR keeps the reusable measurement improvements; it makes no latency-win claim.

The reply selector waits for a new completed assistant group, retaining the unique exact-answer assertion. Firefox can briefly expose a working placeholder beside the answer in a streaming group. Profiling is opt-in; subprocess records contain only the executable basename and timings, with no arguments or environment.

Evidence

Check Result
Script typecheck pnpm tsgo:scripts passed on the unchanged final script content
Real first-run driver Baseline arms completed onboarding, the announced restart, and all three exact replies: 20 Chromium journeys, 20 Firefox journeys and 1 WebKit journey in the last matrix; the identical-base control arms also completed them
Profiling Separate real-Gateway diagnostic journeys produced CPU profiles, existing reply timeline events and executable-only subprocess timings; timing claims do not use profiled samples
Runtime scope Final diff contains only the four benchmark/documentation files; all explored production changes match the baseline byte-for-byte
Formatting / diff Passed
Production Knip pnpm deadcode:knip passed on the final source
Independent review Final four-file scope reviewed; no actionable P0–P2 findings
UI startup Unchanged: 90,865 B gzip JavaScript / 3 requests, 39,023 B gzip CSS / 1 request; strict base comparison passed, no cap changes

The workload used fresh isolated state, a real Gateway and browser, and a loopback synthetic model with sub-millisecond inference. No operator credentials, live services or visible browser windows were used. Baseline: 25eeb08580614c4dd14bd7b0549e6e999d11d44d. The known teardown failure remains explicit: the Gateway acknowledges shutdown, but some process handles keep it alive until the harness terminates its owned process tree. These runs therefore exited nonzero for shutdown despite completing the journey assertions; this PR does not hide or fix that failure.

Rejected optimization evidence and remaining owners

Predeclared acceptance required at least a 5% target gain, 20 rotated base/control/head triplets with an A/A control in Chromium, Firefox and WebKit, and no affected-flow regression beyond the timing/CPU guardrails. No candidate met it. Failed candidates were stopped rather than spending the remaining engine runs or extending samples for a pass.

Rejected candidate Completed comparison Target result Guardrail that rejected it
Canonical target shortcut + cold-import deferral + trimmed native discovery 20 Chromium and 20 WebKit triplets WebKit setup RPC median −12.46% WebKit first-reply application median +6.98%, p95 +17.30%; third-reply application p95 +62.63%
Direct detector import + trimmed native discovery 20 Firefox and 20 Chromium triplets Chromium setup RPC median −12.17%, p95 −5.17% Chromium third-reply readiness p95 +21.99%, process CPU median +23.93%
Trimmed native discovery only 20 Chromium and 20 Firefox triplets; 1 WebKit triplet Chromium setup RPC median −20.92%, p95 −6.78%; Firefox median −11.35%, p95 −32.08% Firefox first-reply readiness median +8.91%, p95 +38.07%; second-reply main-thread CPU p95 +23.53%

The unchanged controls also moved, so these are failed acceptance results, not established causal explanations. In the last candidate, Chromium's third-reply p95 rose 25.52% while its A/A control rose 26.88%; aggregate CPU and work counts improved. A predeclared ten-pair extension for that uncertainty became unnecessary when the completed Firefox result rejected the candidate independently. No unfavorable samples were removed and no performance change remains in the PR.

A single profiled baseline journey attributed first-reply preparation to pre-dispatch admission (~1,983 ms), session initialization (~720 ms; hydration ~542 ms and writer ~177 ms), skills (~157 ms), and system-prompt preparation (~384 ms, including memory acquisition ~364 ms). Diff-baseline preparation (~299 ms) already overlaps; these inclusive/nested diagnostic spans must not be summed. Synthetic inference was under 1 ms. Session admission/hydration belongs to the session/database owners; memory acquisition belongs to Memory Core. No existing safe code-only warmup or empty-memory gate was found that preserves the first reply's context, and the real first-run UI does not create the session before its first send.

Reproduce the extended workload with scripts/bench-control-ui-rpc-payloads.ts --first-run --engines chromium,firefox,webkit --samples 20 --profile local --idle-ms 0 --no-rpc-observer; comparison mode uses --compare-entry and --compare-bundle-dir for the base runtime/UI. Add --server-profile only to a separate diagnostic journey. Full instructions are in scripts/bench-control-ui-rpc-payloads.md.

LOC in the four changed files: 2,419 → 2,509 (+90). Production runtime LOC: unchanged. No visual behavior changes or screenshots are needed.

Compile only model info for disposable Apple Foundation Models discovery and load the setup detection owner without the activation barrel. Keep full optimized inference compilation on explicit selection.

Extend the isolated first-run workload with opt-in server attribution and a third real reply. Performance acceptance is measured separately; no session or database runtime behavior changes.
Keep the strict unique reply assertion while excluding the streaming working placeholder from readiness. Firefox can expose that placeholder beside the reply during the third turn.
Isolate the Apple info-only compilation change. The wider setup candidate improved detection medians but failed later-turn latency and CPU guardrails, so retain the existing detector barrel and its tests.
The Apple-only candidate improved setup detection but failed first-reply and later CPU guardrails in the paired Firefox run. Restore the native helper and retain only the reusable first-run benchmark improvements.
@steipete steipete added the ci:full Keep ordinary native-locale CI selection on the next PR run. label Nov 8, 2026
@clawsweeper

clawsweeper Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T11:07:57.640573Z b270adf PR opened
ℹ️ 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: S labels Nov 8, 2026
@steipete
steipete enabled auto-merge (squash) November 8, 2026 11:13
@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Nov 8, 2026
@steipete
steipete merged commit dad2ce8 into main Nov 8, 2026
113 of 115 checks passed
@steipete
steipete deleted the solid2/w-perf-first-run-server-1107 branch November 8, 2026 11:18
@steipete

steipete commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

vincentkoc added a commit that referenced this pull request Nov 8, 2026
…tooling-lint-selection-20261108

* commit 'b0e90e6a4b359fff7756698067fdce4758b1907b': (38 commits)
  fix(android): Talk button demands a realtime provider on a native Talk setup (#191194)
  chore: trace first-run Gateway work and verify later replies (#195185)
  fix(knowledge): keep deleted messages out of reply previews (#195126)
  fix(agents): preserve streamed replies across Gateway restarts (#195164)
  perf(ci): reuse SDK transport path boundaries (#195180)
  fix(sandbox): avoid pauses for unchanged command checkpoints (#195120)
  fix(test): make retention checks portable across runtimes (#195091)
  fix(knowledge): clarify temporal kind filters (#194995)
  improve: reduce Gateway allocation while draining SQLite receipts (#195129)
  fix: reduce streaming CPU after reply and voice directives (#195145)
  fix: reduce Markdown reparsing during streamed tool-call checks (#195161)
  fix: restore the main dead-export gate (#195158)
  improve(ci): pack small UI selections into fewer jobs (#195107)
  fix(muse): quota and sign-in failures end with no reply (#195148)
  fix: allow first release push with shipped patch bytes (#195174)
  fix(ci): narrow single-config tooling selections (#195147)
  fix(packaging): reject incompatible prepublish plugin cohorts (#195152)
  fix(ci): prepare verified Bun before parity checks (#195155)
  fix: Incognito agent turns stall before execution (#195005)
  fix: credentialed search and speech providers work without picking a provider (#195169)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 9, 2026
…w#195185)

* perf(gateway): trim cold setup detection work

Compile only model info for disposable Apple Foundation Models discovery and load the setup detection owner without the activation barrel. Keep full optimized inference compilation on explicit selection.

Extend the isolated first-run workload with opt-in server attribution and a third real reply. Performance acceptance is measured separately; no session or database runtime behavior changes.

* test(perf): wait for completed first-run replies

Keep the strict unique reply assertion while excluding the streaming working placeholder from readiness. Firefox can expose that placeholder beside the reply during the third turn.

* perf(gateway): keep setup detection import timing unchanged

Isolate the Apple info-only compilation change. The wider setup candidate improved detection medians but failed later-turn latency and CPU guardrails, so retain the existing detector barrel and its tests.

* test(perf): retain diagnostics after rejecting runtime candidates

The Apple-only candidate improved setup detection but failed first-reply and later CPU guardrails in the paired Firefox run. Restore the native helper and retain only the reusable first-run benchmark improvements.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:full Keep ordinary native-locale CI selection on the next PR run. clawsweeper:intake:feature Preliminary submission classification; full source review pending. scripts Repository scripts size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant