Skip to content

Drain up to maxServerRecvPacketsPerLoop per EVB iteration#455

Open
afrind wants to merge 1 commit into
facebook:mainfrom
afrind:export-D106145721
Open

Drain up to maxServerRecvPacketsPerLoop per EVB iteration#455
afrind wants to merge 1 commit into
facebook:mainfrom
afrind:export-D106145721

Conversation

@afrind
Copy link
Copy Markdown
Contributor

@afrind afrind commented May 23, 2026

Summary:
On the shouldUseWrapperRecvmmsgForBatchRecv path, QuicServerWorker::onSocketReadable previously issued a single recvmmsg(2) per notification. Since the adapter sets shouldOnlyNotify=true, folly's own read loop (which honors setMaxReadsPerEvent) does not run, making transportSettings_.maxServerRecvPacketsPerLoop effectively dead on this path — the per-iteration cap collapsed to maxRecvBatchSize.

Wrap the recvmmsg call in an outer while (totalRecvd < maxServerRecvPacketsPerLoop) loop, breaking out on any NoReadReason (EAGAIN signals the kernel buffer drained) and returning on error. This restores the per-EVB-iteration cap to match the legacy socket_->resumeRead(this) path, where folly's read loop has always done the same thing.

We rely on level-triggered EV_READ to re-fire on the next EVB iteration if we hit the cap with data still buffered — no runInLoop re-arm needed.

Differential Revision: D106145721

Summary:
On the `shouldUseWrapperRecvmmsgForBatchRecv` path, `QuicServerWorker::onSocketReadable` previously issued a single `recvmmsg(2)` per notification. Since the adapter sets `shouldOnlyNotify=true`, folly's own read loop (which honors `setMaxReadsPerEvent`) does not run, making `transportSettings_.maxServerRecvPacketsPerLoop` effectively dead on this path — the per-iteration cap collapsed to `maxRecvBatchSize`.

Wrap the recvmmsg call in an outer `while (totalRecvd < maxServerRecvPacketsPerLoop)` loop, breaking out on any `NoReadReason` (EAGAIN signals the kernel buffer drained) and returning on error. This restores the per-EVB-iteration cap to match the legacy `socket_->resumeRead(this)` path, where folly's read loop has always done the same thing.

We rely on level-triggered `EV_READ` to re-fire on the next EVB iteration if we hit the cap with data still buffered — no `runInLoop` re-arm needed.

Differential Revision: D106145721
@meta-cla meta-cla Bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant