Repository navigation
tcp: in incremental mode a recv waiting for a buffer no longer brings the table walk, only a look at the recvs waiting - #655
Merged
Conversation
… the table walk, only a look at the recvs waiting A recv parked on -ENOBUFS makes the sweep walk the table, to take back what connections their handler let go hold. From the shared ring any of them can end the wait. With a ring per connection only the one waiting can, and then only once its handler has let go, so the walk served nothing for as long as a handler was too busy to read an upload. The sweep now looks at the recvs waiting alone in that mode, and gives back what one's handler let go of. It cannot leave that out too: a connection whose handler lets go of a dry ring would never see its client close, and keep its descriptor. Condemned ones are let go of as before, walk or no walk.
MDA2AV
force-pushed
the
fix/incremental-starved
branch
from
November 23, 2026 17:14
61a4f30 to
ba055bc
Compare
Merged
MDA2AV
added a commit
that referenced
this pull request
Nov 23, 2026
All twelve csproj Version elements, 0.28.652 to 0.29.656. Carries the 3 PRs from #653 to #655. Package validation against 0.28.652, in strict mode, finds no API change in any of the eleven published packages. Suites on this tree: Unit 403, Pg 10 (19 skipped, no server here), Redis 1 (7 skipped and 1 pending, no server here). On the same code before the bump: E2E 816 (1 kTLS skip), Http 113, Chaos 105, File 14, Tls 217 (41 kTLS skips, no tls module here).
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.
#653 makes the sweep walk the connection table only when something needs it. One of those things is a recv parked on -ENOBUFS: the walk takes back what connections their handler let go still hold, so the recv can go on. With the shared ring any of those buffers can serve it. With a ring per connection (
Incremental) none of them can, only the connection's own, and those are full because its handler has not read them. So a single upload that gets ahead of its handler brought the walk back on every tick until the handler read, and it could not help. Found in the review of #653. Main walks on every tick whatever the mode, so this was no regression.The recv itself needs no help in the meantime: the kernel ends it with one -ENOBUFS, the data stays in the socket until TCP stops the client, and the recv is submitted again when a buffer comes back.
What changes
In incremental mode the sweep looks at the recvs that are waiting (
_recvStarved), and gives back what one's handler has let go of. It makes no walk for them. That part cannot simply go: a handler that lets go of a ring it never read leaves nobody to empty it, the recv never sees the client close, and the connection keeps its descriptor. With the check left out, "a connection whose handler let go holding a dry ring is closed when its client leaves, with no read timeout" fails.The pass that closes a condemned connection whose recv is parked still runs on every tick that used to make the walk, so at a stop with no clock set it is there as before. Shared mode is unchanged.
Per tick in incremental mode: the recvs waiting, almost always none, instead of the whole table while any is. Nothing changes per request.
Tests
In
TcpSweepTests:Both, with the existing incremental and let-go tests, fail on the mutants that matter: the waiting recvs given nothing back, the walk made anyway, no walk in shared mode either, the buffers of a live handler given back, and no pass over condemned parked recvs. 10 of 10 repeat runs and 3 of 3 on one core are clean.
On main with #653 and #654 merged:
tlsmodule on this box)Overlap
git merge-tree --write-treeagainst every open PR: this adds no conflict to #653's.🤖 Generated with Claude Code