Repository navigation
perf(cli): coalesce streaming-chunk posts per chunkId (latest wins, one in flight) - #999
Merged
Merged
Conversation
…ne in flight) 2026-10-29 p99 alert: one CLI posted 10-30 cumulative streaming-chunk snapshots per second for the same chunkId. A new StreamingChunkCoalescer paces both publishers (ACP AcpPublisher and the PTY StreamingEmitterService): the first snapshot goes out at once, then at most one request in flight and >=100 ms between posts per chunkId, latest content wins. The isFinal frame supersedes anything pending, skips the spacing wait and is always sent after the in-flight request, so it is the last post of its chunkId; late non-final snapshots after it are dropped. chunkIds never wait on each other. Big snapshots (>=8 KB) keep their 300 ms window. Shutdown flushes pending content. Measured on a simulated 20 updates/s stream (10 s): 201 -> 102 posts at 60 ms request latency, 201 -> 35 at 300 ms. Bead: codeagent-p6nu Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Why
2026-10-29 p99 alert: one CLI posted 10-30
POST /api/sessions/:id/streaming-chunkper second, each carrying the CUMULATIVE content of the same chunkId. The backend now caches the share-recipient read; this stops the flood at the source. Beadcodeagent-p6nu.What
New
apps/cli/src/services/streaming/chunk-coalescer.ts(StreamingChunkCoalescer), used by both publishers of the feed:AcpPublisher.publishStreamingChunk(ACP agents) — replaces the >=8 KB-only coalescing; big snapshots keep their 300 ms window, smaller ones get 100 ms.StreamingEmitterService(PTY agents) — its POSTs (with their retry) now go through it;stop()flushes.The VS Code extension and the JetBrains plugin do not post this endpoint.
Per chunkId:
isFinalsupersedes anything pending, skips the spacing wait, is sent right after the in-flight request and is always the last post; later non-final snapshots of that id are dropped (monotonic);Shutdown: the ACP SIGINT/SIGTERM path awaits
publisher.flushStreamingChunks()(bounded to 2 s); turn close already sendsisFinalfor every open chunk, which supersedes any pending snapshot. Errors keep their current handling (sendnever throws; PTY keeps its retry inside one send).Measured
Simulated 20 updates/s stream for 10 s (
chunk-coalescer.test.ts):Tests
__tests__/services/chunk-coalescer.test.ts(fake timers): burst of 30 → 2 posts with the last content; done always last and delivered after in-flight; in-flight + newer → only latest; monotonic ordering; two interleaved chunkIds; flush; send failure; the measurement.acp.publisher.streaming-chunk-cap.test.ts: the "every small delta is posted" case now asserts the new pacing; added a flush case.tsc --noEmitclean.🤖 Generated with Claude Code