dotnet: bound a channel's receive queue by bytes, not by 32 items - #61
Merged
Merged
Conversation
A healthy shell could be failed with "channel data is not being consumed fast enough". AgentChannelDataPump queued at most 32 items per channel, whatever their size, so a burst of small PTY output frames (a prompt redraw, a line-at-a-time command) filled it before the pump caught up. dotnet-android-e2e hit exactly that on #60: the probe's SSH session was faulted on a commit whose sibling run passed the same job. The bound is there to cap memory held for a consumer that has stopped, and 32 items capped that at a few hundred bytes for small frames while allowing 1 MiB for 32 KiB ones. The queue is now unbounded as a channel and bounded by what it holds: at most 4 MiB of payload, plus a 16384-item cap so a flood of empty frames cannot grow the queue's own overhead. Bytes are released once an item is delivered, not when it is dequeued, since the item handed to a stalled sink is still in memory. An empty queue always takes the next item, so a single frame larger than the limit is never mistaken for backpressure. Verified: dotnet test dotnet/Meowshell.sln 227/227. New tests: a burst of 4096 three-byte frames into a stalled sink does not fault; a frame over the limit is accepted into an empty queue; a consumer that keeps up receives 3x the limit without faulting. Each rule was mutated and a test failed: item cap back to 32 (burst test), no empty-queue exemption (oversize test), no byte limit (stall test), bytes never released (running-total test). The two existing stall tests now overflow by bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013WM5HyhwRLKBDyHR6qitkk
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.
Problem
A healthy SSH session could fail with
channel data is not being consumed fast enough.AgentChannelDataPumpqueued at most 32 items per channel, whatever their size. A burst of small PTY output frames, such as a prompt redraw or a command that prints line by line, filled the queue before the consumer caught up.dotnet-android-e2eon ci: run the Go agent E2E suite on Windows, and fail if it skips #60. The Android probe's SSH session was faulted on a commit whose sibling run passed the same job.Fix
MaxQueuedBytes).MaxQueuedItems), so a flood of empty frames can't grow the queue's own overhead.Verification
Full suite:
dotnet test dotnet/Meowshell.slnpasses, 227/227.New tests:
Mutation checks (each rule broken on purpose; a test failed every time):
Existing tests: the two stall tests and
ReceiveBackpressureRequestsRemoteChannelCleanupExactlyOncenow overflow the queue by bytes, using 32 KiB frames (the agent's read size), instead of by item count.🤖 Generated with Claude Code
https://claude.ai/code/session_013WM5HyhwRLKBDyHR6qitkk
Generated by Claude Code