feat(connection): add explicit PauseRead/ResumeRead/IsReadPaused APIs#423
Open
NickPak wants to merge 1 commit into
Open
feat(connection): add explicit PauseRead/ResumeRead/IsReadPaused APIs#423NickPak wants to merge 1 commit into
NickPak wants to merge 1 commit into
Conversation
Expose application-driven read backpressure on the Connection interface: - PauseRead() stop monitoring readable (EPOLLIN) events for this conn - ResumeRead() resume monitoring readable events - IsReadPaused() report whether readable monitoring is currently paused These are minimal mechanisms that let the application decide *when* to apply TCP backpressure based on its own signal (downstream/outbound queue depth, work-queue high/low watermarks, credits, ...), instead of relying on netpoll's inbound LinkBuffer size, which is not a reliable proxy for application overload (e.g. proxies that drain the inbound buffer quickly into their own queue). Implementation notes: - Read and write interest are now two independent dimensions. The poll mask is recomputed from (readPaused, writeWatching) on every transition; adds PollR2N/PollN2R/PollN2W/PollW2N alongside the existing PollRW2W/PollW2RW so read can be toggled without disturbing a pending write and vice versa. - When read is paused and there is no pending write, the connection drops to "no interest" rather than write-only, avoiding a level-triggered EPOLLOUT busy-spin on receive-mostly connections. - Transitions are serialized with a per-connection mutex: the two dimensions are mutated by different goroutines (application vs poller) and epoll_ctl(MOD) sets an absolute mask, so atomics alone cannot order "state change + syscall". - PauseRead/ResumeRead are guarded by IsActive() to avoid calling Control() on a freed operator after close. - epoll (Linux) and kqueue (BSD) control paths updated. - Added TestConnectionPauseResumeRead. No behavior change unless the new APIs are called. Signed-off-by: NickPak <bc92@foxmail.com>
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.
Expose application-driven read backpressure on the Connection interface:
These are minimal mechanisms that let the application decide when to apply TCP backpressure based on its own signal (downstream/outbound queue depth, work-queue high/low watermarks, credits, ...), instead of relying on netpoll's inbound LinkBuffer size, which is not a reliable proxy for application overload (e.g. proxies that drain the inbound buffer quickly into their own queue).
Implementation notes:
No behavior change unless the new APIs are called.