Conversation
Owner
Author
|
6.12 incremental buffers experimental feature added.. |
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
IOU_PBUF_RING_INC (kernel 6.12+) lets the kernel partially consume a buffer across multiple recv CQEs. But the buffer ring was shared across all connections on a
reactor — so data from different connections would interleave in the same buffer, corrupting everything.
Solution
When IncrementalBufferConsumption = true, each connection gets its own buffer ring with a unique buffer group ID (bgid). When false, the shared reactor ring works
exactly as before (zero behavior change).
ReactorConfig.csConnectionBufferRingEntries = 128(per-connection ring size)MpscUlongQueue.csulong, carries packed(fd, bid)pairs for incremental buffer returnsConnection.csBufRing,BufRingSlab,Bgid,IncrementalMode,BufRefCounts,BufKernelDone,BufCumulativeOffset.Clear()andDispose()Connection.Read.LowLevelApi.csReturnRing()routes to incremental queue whenIncrementalModeis setEngine.Reactor.cs_freeGidsstack),SetupConnectionBufRing/TeardownConnectionBufRing,ReturnConnectionBuffer(with offset reset),EnqueueReturnQIncremental/DrainReturnQIncremental, updatedInitRing()andCloseAll()Engine.Reactor.Handle.csEngine.Reactor.HandleSubmitAndWaitCqe.csEngine.Reactor.HandleSubmitAndWaitSingleCall.csCQE's data starts. Reset to 0 when buffer is returned.
IORING_CQE_F_BUF_MORE). Buffer returns to ring only when both refcount == 0 AND kernel done.
buffer to kernel ring.
Validated
99.9% buffer reuse ratio under pipelined HTTP load (~675 recv completions per 32KB buffer on average).