Skip to content

feat(perf): separate session and first tool resource costs - #157744

Merged
vincentkoc merged 7 commits into
mainfrom
feat-resource-session-first-warm-20260925
Sep 25, 2026
Merged

vincentkoc merged 7 commits into
mainfrom
feat-resource-session-first-warm-20260925

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Related: #155730

What Problem This Solves

The resource profile hides session creation and mixes the first tool call with later calls, so maintainers cannot distinguish those costs.

User Impact

The existing profiling mode reports one asserted session creation plus first-call and warm-call costs. Normal Gateway behavior and the workload's one session and 20 tool calls are unchanged.

Why This Change Was Made

The canonical measurement helper splits the original tool workload into first (1) and warm (19) receipts sharing one midpoint snapshot. The existing 20-call aggregate still uses its outer raw snapshots; it must not be added to its children. Failed observations preserve completed-call counts and stop further work, while later failure retains a successful first receipt.

These are whole-Gateway measurements in an already started host, including midpoint sampling overhead. They do not isolate schema construction, cold loading, plugin allocation or child CPU. Session and tool work have no empty-host subtraction.

This integration also removes one duplicate baseline assignment introduced when the concurrent canonical survivor fixture fix and PR #157996 landed together. The final fixture is byte-identical to the canonical fix; its strict shell checks and all assertions remain intact.

Evidence

  • Focused native Testbox proof on Node 24.19: 131 tests passed across the two profiler test files; three existing Bun-entry cases skipped because Bun was unavailable. One native shard took 17.51 s (17.775 s command wall time), without an explicit worker-count override. Direct cases cover RPC order/arguments, first/warm counts, shared boundaries, partial failures, missing/malformed samples, PID/environment changes and signed memory deltas.
  • Original five-file formatting passed in 136 ms. The additional one-line fixture cleanup passed focused formatting and the canonical line-cap ratchet; diff checks and independent source reviews are clean.
  • One isolated empty/conformance resource pair passed with harness f0a24a62, genuine published OpenClaw 2026.9.6 host eb377ac5, Kitchen Sink fixture 051db418, and Crabpot consumer 43782aa7. One immutable image ran network-isolated with 2 CPUs/4 GiB. Fixture packing verified committed contents; the host archive matched its pinned SHA-256 and release integrity. This does not claim a full candidate core build or a pnpm-frozen image dependency closure.
  • The report asserts session 1, first call 1, warm calls 19 and aggregate calls 20. Raw CPU, wall, memory and shared-boundary arithmetic reconcile. Single-sample whole-Gateway process CPU was 130.432 ms for session creation, 67.551 ms for the first call and 28.967 ms per warm call. These are correctness-proof observations, not a performance comparison; no workload calls were added.
  • Crabpot aggregate/calibration admission passed. The landed split consumer independently re-admitted the retained report with session/first/warm credit. Inventory runtime coverage remains separate. CPU and held-buffer calibration signals were observed; timer-count signals were inconclusive. Both Gateways exited 0, the container was confirmed absent, and native one-shot Testbox cleanup completed.
  • Signed head bf3aeccb0b85cafb6ead6579163c78c4c4bb7c7d integrates frozen fixed main 6f51289a. All original five contribution blobs and their complete patch remain identical to reviewed f0a24a62; all eighteen local runtime dependency modules and the optional pnpm runner are unchanged. The historical focused/runtime evidence therefore retains its original harness/released-host scope. No Gateway rerun or whole integrated-core runtime claim is made.
  • The previous head's required-CI failure was the inherited survivor fixture's missing baseline value. The landed fixture repair passed its complete 10-case file, root test types and required CI. Earlier canonical main repairs, including the Gmail reload fixture, are also incorporated. Exact-head CI and Workflow Sanity passed. Native completed-hosted preparation verified both against this head. The current ClawSweeper review covers this exact head with no findings, security issues, before-merge actions or rank-up moves; maintainer review is complete.
  • Scope: six files, 439 additions/42 deletions, 481 changed lines. Production is 110 additions/38 deletions, tests 312 additions/1 deletion, docs 17 additions/3 deletions. Positive production growth owns the new measurement boundary and shared observation-failure handling.

Release-note context: distinguish session creation and first tool invocation from warm tool costs in resource profiling.

@vincentkoc vincentkoc self-assigned this Sep 25, 2026
@clawsweeper

clawsweeper Bot commented Sep 25, 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.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 25, 2026
@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 25, 2026, 3:47 AM ET / 07:47 UTC (Revision 10).

ClawSweeper review

What this changes

The Kitchen Sink resource profiler now measures session creation and separates the first tool call from the remaining 19 in its report, with documentation, tests, and a fixture cleanup.

Merge readiness

✅ Ready for maintainer review

Current main still reports session creation outside the measured phases and combines all tool calls into one receipt. This PR supplies distinct measurements, and the reviewed source, real Gateway observations, and merged consumer contract support keeping it as the active change.

Priority: P2
Reviewed head: bf3aeccb0b85cafb6ead6579163c78c4c4bb7c7d

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused implementation has specific real Gateway observations, consumer compatibility evidence, and boundary tests without an actionable finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured isolated Gateway run exercised the changed resource-profile path and reported the after-change 1/1/19/20 receipts with reconciling snapshots; matching profiling blobs carry that evidence to this head, whose additional edit is fixture cleanup. The merged Crabpot reader validates the split and still accepts legacy aggregate-only reports, providing report-format compatibility without a migration.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured isolated Gateway run exercised the changed resource-profile path and reported the after-change 1/1/19/20 receipts with reconciling snapshots; matching profiling blobs carry that evidence to this head, whose additional edit is fixture cleanup. The merged Crabpot reader validates the split and still accepts legacy aggregate-only reports, providing report-format compatibility without a migration.
Evidence reviewed 8 items Current-main gap: Current main samples all 20 plugin tool calls as one phase and creates the session before that phase.
Changed production path: The workload measures one asserted session creation, then requests a first/warm split for the existing tool-call count.
Receipt arithmetic: The helper shares one midpoint snapshot between the first and warm receipts while retaining the original outer snapshots for the 20-call aggregate; failed observations retain completed-call counts.
Findings None None.
Security None None.

How this fits together

The opt-in Kitchen Sink profiler runs a fixed workload against an isolated OpenClaw Gateway and samples that process at workload boundaries. It writes a resource report for performance investigations and downstream readers.

flowchart LR
A[Resource profile request] --> B[Isolated Gateway]
B --> C[Session creation]
C --> D[First tool call]
D --> E[19 warm tool calls]
B --> F[Boundary snapshots]
C --> F
D --> F
E --> F
F --> G[Resource report]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +325, Other +72. Total +397 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 4 329 4 +325
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 110 38 +72
Total 6 439 42 +397

Review metrics

Metric Value Why it matters
Code growth production +72 net; tests +311 net The production growth adds the measurement boundary and failure receipts, with focused tests for their behavior.
Measured workload 1 session; 1 first + 19 warm = 20 tool calls The split preserves the original tool workload rather than adding calls to obtain a warm sample.

Technical review

Best possible solution:

Keep the split in the existing profiling harness and retain the 20-call aggregate and legacy-report compatibility as the report reaches consumers.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this requests finer profiling output. Current-main source confirms that session creation is unmeasured and tool calls have only an aggregate receipt.

Is this the best way to solve the issue?

Yes: extending the existing resource-profile harness keeps measurement and report ownership together while preserving the established aggregate.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 932abb0a841b.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded improvement to maintainer performance diagnostics with no reported core-runtime regression.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured isolated Gateway run exercised the changed resource-profile path and reported the after-change 1/1/19/20 receipts with reconciling snapshots; matching profiling blobs carry that evidence to this head, whose additional edit is fixture cleanup. The merged Crabpot reader validates the split and still accepts legacy aggregate-only reports, providing report-format compatibility without a migration.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured isolated Gateway run exercised the changed resource-profile path and reported the after-change 1/1/19/20 receipts with reconciling snapshots; matching profiling blobs carry that evidence to this head, whose additional edit is fixture cleanup. The merged Crabpot reader validates the split and still accepts legacy aggregate-only reports, providing report-format compatibility without a migration.

Evidence

What I checked:

  • Current-main gap: Current main samples all 20 plugin tool calls as one phase and creates the session before that phase. (scripts/e2e/kitchen-sink-rpc-walk.mts:3152, 932abb0a841b)
  • Changed production path: The workload measures one asserted session creation, then requests a first/warm split for the existing tool-call count. (scripts/e2e/kitchen-sink-rpc-walk.mts:2885, bf3aeccb0b85)
  • Receipt arithmetic: The helper shares one midpoint snapshot between the first and warm receipts while retaining the original outer snapshots for the 20-call aggregate; failed observations retain completed-call counts. (scripts/e2e/lib/kitchen-sink-resources.mts:126, bf3aeccb0b85)
  • Boundary tests: The added tests check RPC order and arguments, shared sample boundaries, aggregate counts, partial failures, and unavailable or invalid samples. (test/scripts/kitchen-sink-resources.test.ts:29, bf3aeccb0b85)
  • Recorded real behavior: The captured PR body reports an isolated published-Gateway run with one session, one first call, 19 warm calls, and a 20-call aggregate, including raw resource arithmetic. That run used the earlier profiling source; the five profiling file blobs at that source and the reviewed head have matching Git object IDs. (bf3aeccb0b85)
  • Downstream report contract: The merged consumer validates session, first, warm, and aggregate counts and their shared boundaries, while retaining acceptance of older aggregate-only reports. (scripts/resource-coverage.mjs:95, db47eede291b)

Likely related people:

  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-25T01:52:28.847Z sha f0a24a6 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-25T02:43:54.340Z sha 13e901a :: needs maintainer review before merge. :: none
  • reviewed 2026-09-25T04:23:20.725Z sha 0cc2820 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-25T04:36:31.555Z sha 0cc2820 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-25T05:56:36.696Z sha f4d4a0e :: needs maintainer review before merge. :: none
  • reviewed 2026-09-25T06:11:32.259Z sha f4d4a0e :: needs maintainer review before merge. :: none
  • reviewed 2026-09-25T07:08:24.813Z sha 43680bc :: needs maintainer review before merge. :: none
  • reviewed 2026-09-25T07:23:03.723Z sha 43680bc :: needs maintainer review before merge. :: none

@vincentkoc
vincentkoc marked this pull request as ready for review September 25, 2026 00:21
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 25, 2026
* commit '05edd36e124dc376f63475256f45e82ec437412c': (30 commits)
  refactor(matrix): reuse bounded direct-room cache insertion (#157775)
  fix: preserve channel-owner revocation across recovery (#157709)
  fix(ci): stop blocking CI during release validation (#157757)
  refactor(tlon): remove unreachable DM summary branches (#157789)
  chore: speed up worktree recovery tests with Bun (#157674)
  fix(sessions): release PR caches when pending viewers leave (#157776)
  refactor(twitch): reuse setup account selection (#157787)
  test: skip empty task ledger resets in cron fixtures (#157767)
  perf: reduce gateway and state test startup (#157711)
  fix: preserve maintenance leases during slow heartbeat renewal (#157696)
  fix(channels): match non-TTY setup advice to registered flags (#157551)
  fix: keep failed update report uploads in the CLI (#156633)
  fix: preserve rejected settings reason when opening config (#157731)
  test(update): load real filesystem dependencies in swap fixture
  fix(ci): prevent Security Review checkout retry collisions (#157652)
  fix(ci): recover interrupted Security Review response bodies (#157651)
  test(ui): capture live operator authority in guest question fixture
  refactor(agents): deslop runners, harness and recovery (#157294)
  fix(auth): preserve Copilot tenant credentials during Doctor repair (#139131)
  refactor(msteams): share stored service URL validation (#157706)
  ...
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: M labels Sep 25, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review current head 0cc2820233f9602a2252b8f6e899059becbf824d. The fixed-main integration preserves the original five contribution blobs and retained runtime harness pins; the updated body separates that evidence from fresh required CI.

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 25, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 25, 2026
@vincentkoc
vincentkoc enabled auto-merge (squash) September 25, 2026 05:59
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 25, 2026
…4-prep

* commit '8fe893da516ebdc817692fb2d272e27bc3c88376': (31 commits)
  fix(test): wait for reload admission before restart polling (#157964)
  refactor(mattermost): reuse DM retry option selection (#157800)
  chore(i18n): refresh native locales (#157850)
  perf(sessions): reuse current participants across transcript appends (#157622)
  refactor(signal): share pending transport migration results (#157777)
  fix(tui): open model pickers without waiting for the Gateway (#157839)
  fix(gateway): apply config despite delayed file notifications (#157906)
  fix(auth): clear deleted account selections and support account recovery (#157745)
  fix: plugin reloads lose tool results and strand subagent settlement (#157339)
  fix(gateway): avoid preview errors during worker metadata updates (#157943)
  refactor(diffs): reuse native promisify for compression (#157835)
  fix(models): keep current choices on the first picker page (#157869)
  fix(plugins): retain existing quarantine across unrelated reloads (#157907)
  fix(openai): prioritize ChatGPT sign-in and clarify auth choices (#157792)
  chore(ui): refresh control ui locales (#157955)
  fix(ui): refresh connected accounts after auth changes (#157950)
  fix(scripts): avoid redundant npm version process in package checks (#157809)
  refactor(usage): capture hosted pricing once per operation (#157838)
  refactor(ui): share slash-command failure results (#157649)
  fix(cron): announce runs miss the channel's formatting rules (#157877)
  ...
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Exact head: 9cc07c4. This incorporates the landed Gmail fixture repair in #157964. All five profiler contribution files and the complete contribution patch remain byte-identical to the previously reviewed source; the PR body preserves the historical runtime scope and required new-head CI gap.

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

…4-prep

* commit 'cb64558f80bcf053ee3f0bf87a60016aa789a287':
  fix(macos): stop repeated Keychain prompts after access is denied (#157951)
  test(macos): await cron fixture readiness before polling
  feat(release): add the resumable release:stable orchestrator (#157941)
  fix(plugins): report retained-work settlement once (#157836)
  fix(doctor): preserve current sessions after restored-index replay (#157615)
  chore(ui): refresh control ui locales (#157978)
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head 43680bc030a3c22012f58f7ba7fc32d6f1b38a63. It integrates the landed hosted-tail cap assertion repair in frozen main cb64558f; all five profiler contribution blobs and the released-host harness closure remain unchanged. The updated PR body separates historical proof, the prior failed CI assertion, and pending new-head required checks.

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. label Sep 25, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review bf3aecc — fixed-main integration preserves all five profiler files and the released-host harness closure; the sixth file only removes our duplicate baseline assignment, restoring the canonical concurrent fixture fix. Updated evidence and scope are in the PR body.

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@vincentkoc
vincentkoc merged commit 2d94121 into main Sep 25, 2026
178 checks passed
@vincentkoc
vincentkoc deleted the feat-resource-session-first-warm-20260925 branch September 25, 2026 08:04
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. scripts Repository scripts size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant