openclaw-windows-node icon indicating copy to clipboard operation
openclaw-windows-node copied to clipboard

Battery drain + slowdown with multiple concurrent sessions

Open samanthamsong opened this issue 5 months ago • 9 comments

Problem: Running multiple concurrent sessions causes noticeable battery drain and system slowdown.

Impact: Performance / power — degrades the experience for users running several agent sessions.

Repro: Start multiple sessions and observe CPU/battery over time.

Epic: should ladder up to #837 (S4 - Secure & contained / MXC).

samanthamsong avatar Jul 01 '26 16:07 samanthamsong

Codex review: this still needs some work. Reviewed October 2, 2026, 12:02 AM ET / 04:02 UTC.

Summary Keep open. The September release retest establishes session-roster request amplification, and current main retains the triggering behavior. The earlier lack of a measurable workload is resolved; battery impact and acceptance of the proposed freshness contract remain outstanding. This collaborator-authored issue requires maintainer handling.

Reproducibility: yes. for request amplification: current main maps both session-event names to full roster requests, and the discussion supplies a controlled official-release workload. This review did not execute it, and battery drain itself is not established.

Maintainer decision needed

Question Recommendation
Should event-driven session-roster refreshes use the proposed two-second attempt limit with immediate first refresh, one trailing refresh, and unchanged explicit refreshes? Approve the bounded contract: Approve the proposed two-second contract and coordinate its implementation with the narrower refresh work already tracked.

Why: The workload now establishes amplification, but choosing acceptable roster staleness changes the native session experience and requires maintainer intent.

Next step Approve a freshness contract and coordinate with https://github.com/openclaw/openclaw-windows-node/issues/1569 before starting separate work; collaborator authorship and the unresolved policy choice exclude automatic repair intake.

Review details

Best possible solution:

Use one lifecycle-bound event-refresh scheduler with immediate first delivery, bounded attempts, trailing reconciliation, observed failures, and unchanged explicit refreshes under an approved freshness contract.

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

Yes for request amplification: current main maps both session-event names to full roster requests, and the discussion supplies a controlled official-release workload. This review did not execute it, and battery drain itself is not established.

Is this the best way to solve the issue?

Yes for event-only coalescing rather than globally throttling explicit refreshes; the proposed interval still needs approval. Preserve profile invalidation, connection gating, and eventual final-state delivery.

AGENTS.md: found and applied where relevant.

Remaining risk / open question:

  • The proposed two-second freshness limit has no recorded maintainer acceptance.
  • Request amplification is demonstrated, but controlled client battery and slowdown measurements remain unestablished.

Codex review notes: model internal, reasoning medium; reviewed against 85f66247850e.

Label changes

Label changes:

  • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
  • add clawsweeper:source-repro: Current issue advisory state selects this label.
  • remove issue-rating: 🐚 platinum hermit: Current issue advisory state no longer selects this label.
  • remove clawsweeper:needs-live-repro: Current issue advisory state no longer selects this label.

Label justifications:

  • P2: Measured roster amplification warrants a bounded performance improvement without established battery drain, crash, or blocked workflow.
  • impact:other: The demonstrated impact is excess session-roster traffic and processing cost.
Evidence reviewed

What I checked:

  • Verified review revision and policy: Origin identifies the target repository; checkout is the fetched main revision. The full root AGENTS.md was read, including connection ownership and proof guidance. No files were changed and no builds or tests were executed. (AGENTS.md:1, 85f66247850e)
  • Current main retains unbounded event refreshes: sessions.changed immediately calls RequestSessionsAsync at line 3525; the session handler does the same at line 4345. RequestSessionsAsync sends a complete sessions.list request without an event-refresh scheduler. (src/OpenClaw.Shared/OpenClawGatewayClient.cs:3525, 85f66247850e)
  • New measured release reproduction: The September 16 comment reports official Companion 2026.9.4 producing 92 Companion-attributed roster responses versus 25 with private two-second coalescing, under 100 successful session-label patches over about 50 seconds. It explicitly excludes proof of battery drain or a memory leak. https://github.com/openclaw/openclaw-windows-node/issues/906#issuecomment-5702569518. (3c43751b2bac)
  • Concrete proposed freshness contract: The September 4 comment proposes an immediate first refresh, at most one event-driven attempt per two seconds, one trailing refresh, throttled failed attempts, and unchanged explicit refreshes. Its reported loopback workload reduced 101 requests to 2; maintainer acceptance was requested rather than granted. https://github.com/openclaw/openclaw-windows-node/issues/906#issuecomment-5547595053.
  • Existing explicit refresh and profile behavior: Native /new reconciliation explicitly refreshes sessions; profile-identity events separately invalidate the self profile. An event coalescer should preserve these existing paths rather than throttle every RequestSessionsAsync caller. (src/OpenClaw.Tray.WinUI/Chat/OpenClawChatDataProvider.cs:366, 85f66247850e)
  • Related narrower work and measurement limits: https://github.com/openclaw/openclaw-windows-node/issues/1569 is open and targets the same event-refresh calls plus discarded failures. Its discussion records an implementation attempt. Its zero-send inference is unsupported: the cited frame log belongs to the wizard sender, and suppressed tracked requests do not call ParseSessions. No fixing PR was returned by the bounded related-PR search. (src/OpenClaw.Shared/OpenClawGatewayClient.cs:2249, 85f66247850e)

Likely related people:

  • karkarl: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • bkudiess: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • shanselman: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
How this review workflow works
  • 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.

clawsweeper[bot] avatar Jul 01 '26 16:07 clawsweeper[bot]

This issue has been automatically marked as stale due to inactivity. Please add updated OpenClaw Windows details or it will be closed.

github-actions[bot] avatar Jul 25 '26 04:07 github-actions[bot]

I can provide a high-confidence reproduction and a bounded freshness contract for this issue.

Reproduction

Environment:

  • OpenClaw Companion for Windows: 2026.7.1-4
  • OpenClaw Gateway: 2026.9.1
  • Companion open and idle; no manual session-list refreshes during the sample
  • Existing gateway with concurrent background session activity

Observed behavior:

  • 92 sessions.list requests in approximately 31 seconds: about 178 requests/minute.
  • In an earlier one-minute sample, the Companion connection generated 216 of 238 sessions.list requests.
  • Closing the Companion stopped that connection immediately. A subsequent 67-second control sample contained 11 requests from the web client only, followed by a zero-request minute.
  • Gateway host CPU fell from 30.25% during the flood to 2.93% after the Companion closed. This is correlation rather than a client battery measurement, but it demonstrates the server-side cost of the amplification.

Current main still maps each session or sessions.changed event directly to a full sessions.list request.

Proposed behavior contract

  • The first session event after an idle period refreshes the roster immediately.
  • During sustained activity, event-driven roster refreshes are limited to one attempt every two seconds.
  • Events arriving during the interval are coalesced into one trailing refresh, preserving final state.
  • Failed send attempts observe the same limit, avoiding a retry flood on a broken connection.
  • Explicit and user-initiated refreshes remain unchanged.

Deterministic proof

A real loopback-WebSocket regression sends one initial event followed by a 100-event burst across both supported session-event names:

  • Current main: 101 events produce 101 sessions.list requests.
  • Proposed change: the same workload produces 2 requests, including the trailing refresh.
  • A second test verifies that failed sessions.list sends remain rate-limited.
  • Focused stress passed 10/10 runs; the related Gateway client test surface passed 260/260 tests.

I have the focused patch ready. If the two-second freshness contract is acceptable, I can open the PR with the full diff and CI evidence.

HerbertHuerto avatar Sep 04 '26 23:09 HerbertHuerto

Follow-up with a release retest on 2026-09-16: the session-roster refresh amplification is still reproducible in official Companion 2026.9.4 (3c43751b2bace876de3febe478ebabeca172e3ac).

Same Windows laptop and Gateway 2026.9.4, native UI, one Companion process at a time. Each phase applied 100 synthetic session-label patches over approximately 50 seconds to an archived test session; all 100 updates succeeded in both phases. Counts below are sessions.list responses attributed to the Companion connection, not gateway-wide traffic.

Build Companion-attributed sessions.list responses
Official 2026.9.4 92
Private Dev build with the previously proposed two-second coalescing 25

That is 3.68× as many roster responses in the official build for this workload. At the official release tag, both session-event paths still request an immediate roster refresh.

Important limits: this is a bounded request-amplification test, not proof of battery drain or a memory leak. Official had lower measured client CPU and memory in this short run; the Dev process had been running for days, so the memory samples are not a controlled leak comparison. Native Hub/tray chat passed a short smoke, with no Windows application crash. The COM-retention mitigation from #1215 is present; that is separate from roster refresh coalescing.

The proposed freshness contract in my previous comment is unchanged: immediate first refresh, at most one event-driven refresh attempt per two seconds during sustained activity, one trailing refresh, and unchanged explicit/user-initiated refreshes. Is that contract acceptable for a focused PR?

HerbertHuerto avatar Sep 16 '26 18:09 HerbertHuerto

This issue has been automatically marked as stale due to inactivity. Please add updated OpenClaw Windows details or it will be closed.

github-actions[bot] avatar Oct 01 '26 03:10 github-actions[bot]

This issue has been automatically marked as stale due to inactivity. Please add updated OpenClaw Windows details or it will be closed.

github-actions[bot] avatar Oct 18 '26 03:10 github-actions[bot]

Follow-up to the stale notice, 2026-10-18: the event-driven request path remains present in current main and the latest published Windows release. This update is a source verification, not a new runtime or battery retest.

Checked revisions:

  • Main: 61979d6170a0bd3351e21ca5053d6fca5be959c6.
  • Latest release: v2026.9.8-1, commit 2ba89f377ce8ce3f5ddfc452e4d509329f109114.
  • src/OpenClaw.Shared/OpenClawGatewayClient.cs is byte-identical at those two revisions.

Current source evidence:

  1. sessions.changed and HandleSessionEvent still independently discard RequestSessionsAsync() tasks.
  2. RequestSessionsAsync calls the tracked sender without an event-refresh scheduler. The tracked sender preserves handshake gating, registers each admitted request separately, and rethrows send failures.
  3. The transport send lock serializes frames; it does not coalesce session refreshes. Existing UI snapshot coalescing is a separate downstream owner, not a fix for these requests.

The September 16 controlled 92-versus-25 response comparison remains historical runtime evidence only. I have not repeated it on v2026.9.8-1; battery drain, a memory leak, and UI-hang causality are not established by this update. No build or tests were run, and no installed app or Gateway was changed.

Please coordinate the request-coalescing and observed-failure work with #1569 rather than treating this as a separate implementation. Its zero-send inference is not evidence used here. The proposed event-only freshness contract still needs maintainer acceptance: immediate first refresh, a two-second attempt bound during sustained activity, trailing reconciliation, and unchanged explicit refreshes, while preserving profile invalidation and connection lifecycle boundaries. Please keep this tracked while that decision is outstanding, or consolidate the request-amplification scope into #1569.

HerbertHuerto avatar Oct 18 '26 14:10 HerbertHuerto

This issue has been automatically marked as stale due to inactivity. Please add updated OpenClaw Windows details or it will be closed.

github-actions[bot] avatar Nov 03 '26 03:11 github-actions[bot]

Closing due to inactivity. If this still affects OpenClaw Windows, open a new issue with the current version, logs, and fresh reproduction details.

github-actions[bot] avatar Nov 10 '26 03:11 github-actions[bot]