Repository navigation
perf(gateway): per-transcript broadcast lanes - #121104
Merged
Merged
Conversation
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
steipete
marked this pull request as ready for review
August 9, 2026 15:48
steipete
force-pushed
the
perf/session-sync-broadcast-lanes
branch
from
August 9, 2026 16:03
fa71bb6 to
b6c24cf
Compare
Transcript-update broadcasts were serialized behind one global promise queue, so one session's pending async seq read head-of-line blocked every other session's session.message and sessions.changed delivery. Ordering is a per-transcript contract, so key the queue by transcript identity and drop drained lanes. Per-message transcript usage stays derived: session.message payloads carry live totalTokens/estimatedCostUsd as a dashboard API contract (#50101).
steipete
force-pushed
the
perf/session-sync-broadcast-lanes
branch
from
August 9, 2026 16:46
b6c24cf to
a645fad
Compare
The row added in #120727 reused index 6, which belongs to Message audit metadata, so the case toggled the audit row and asserted its patch. Labs features render in registry order, and workerDesktop is the eighth entry.
1 task done
Member
|
I opened #121161 as the narrow Labs test-owner repair. It removes all positional/index-based toggle selection by resolving each named Please drop this PR's one-line |
Contributor
Author
|
Merged via squash.
|
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Aug 10, 2026
* perf(gateway): per-transcript broadcast lanes Transcript-update broadcasts were serialized behind one global promise queue, so one session's pending async seq read head-of-line blocked every other session's session.message and sessions.changed delivery. Ordering is a per-transcript contract, so key the queue by transcript identity and drop drained lanes. Per-message transcript usage stays derived: session.message payloads carry live totalTokens/estimatedCostUsd as a dashboard API contract (openclaw#50101). * fix(ui): target the Cloud Worker Desktop labs row in its toggle test The row added in openclaw#120727 reused index 6, which belongs to Message audit metadata, so the case toggled the audit row and asserted its patch. Labs features render in registry order, and workerDesktop is the eighth entry.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
createTranscriptUpdateBroadcastHandlerserialized every transcript-update broadcast behind one process-wide promise queue. Ordering only matters within a transcript, but the single queue made it global: one session's pending async seq read (readSessionMessageCountAsync, taken whenever an update arrives without a committedmessageSeq) head-of-line blockedsession.messageandsessions.changeddelivery for every other session. Each queued update also does a full gateway session-row build, so a busy session's per-message broadcasts stalled unrelated sessions on multi-agent installs and subagent swarms.Why This Change Was Made
Ordering is a per-transcript contract — subscribers merge each session's updates independently and no consumer depends on cross-session broadcast order. The queue is now a
Mapof lanes keyed by the update's transcript identity (target.sessionKey→sessionKey→sessionFile), so independent sessions proceed concurrently while order within one transcript is preserved. Drained lanes are deleted so idle sessions do not accumulate map entries.Scope note: an earlier revision of this PR also skipped the per-message transcript-usage re-derivation. CI caught that as a regression —
session.messagepayloads carry livetotalTokens/estimatedCostUsdderived from the transcript as a dashboard API contract (#50101), proven bysrc/gateway/session-message-events.test.ts. That part is reverted; per-message usage stays derived under its existing bounded 64KB cap. Reducing that remaining per-message read needs a different fix (recording usage at its producer rather than re-deriving it downstream) and is left as a follow-up.User Impact
A busy session can no longer stall transcript and message updates for other connected sessions. No payload or ordering contract changes.
Evidence
node scripts/run-vitest.mjs run src/gateway/server-session-events.test.ts src/gateway/session-message-events.test.ts— 52 passed (includes the usage-metadata contract test that caught the reverted change).node scripts/run-vitest.mjs run src/gateway/server-runtime-subscriptions.test.ts— 10 passed; earlier full run withsession-utils.test.ts— 169 passed.Production LOC delta: +21 (lane map). Tests +88. Growth justification: the per-transcript ordering fact is now recorded at the boundary that enforces it.
Found by a full syncing-logic audit; separate follow-ups tracked for cloud-worker workspace-sync repeated full-tree hashing and its 25ms directory-walk poll, auth-profile throwaway SQLite handles, per-turn sandbox skill wipe/recopy, and
sessions.patchkey scoping.Unrelated main breakage fixed here
mainis red onchecks-node-compact-large-6independently of this PR (its own run on5b6c19d9fails the same job). Cause:ui/src/pages/labs/labs-page.test.tsgives the "Cloud Worker Desktop" caseindex: 6, which is the "Message audit metadata" row — the row added in #120727 reused the previous index instead of taking the next one. Labs rows render inLAB_FEATURESregistry order andworkerDesktopis the eighth entry, so the case toggled the audit row and asserted the audit patch. Reproduced locally on an unmodified UI tree before the fix and green after (node scripts/run-vitest.mjs run ui/src/pages/labs/labs-page.test.ts— 44 passed). Per repo policy the merge gate is not bypassed; the smallest correct fix rides in this landing PR as a separate commit.