Repository navigation
Conversation
resetius
force-pushed
the
read-buffer-uring
branch
2 times, most recently
from
November 15, 2026 22:15
af48349 to
fdd9b9b
Compare
resetius
force-pushed
the
read-buffer-uring
branch
from
November 15, 2026 22:25
fdd9b9b to
fa03c20
Compare
resetius
marked this pull request as ready for review
November 15, 2026 22:40
resetius
marked this pull request as draft
November 15, 2026 23:25
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.
Depends on #209 (stacked: the diff of this PR is the second commit only).
TUring reads ahead for
ReadBuffer(): the first wait on a descriptor arms one multishot request, and the kernel picks the buffers from a provided buffer ring.IORING_OP_RECVmultishot. Pipes and other pollable files:IORING_OP_READ_MULTISHOT. Regular files (multishot answers-EBADFD): one buffer-select read at a time.TReadBufferConfig::Countbuffers of the pool (io_uring_setup_buf_ring, set up at the firstReadBuffer()).~TReadBufferputs the buffer back into the ring.-ENOBUFS(ring empty): the descriptor waits and is armed again when a buffer comes back.PerSocketLimit: at that many queued leases the multishot is cancelled. It is armed again when the reader waits on an empty queue, and the rest waits in the socket. The limit is checked as completions arrive, so one wake-up that reads a burst can go over it.ECANCELED, asReadSome()does today. user_data carries(fd, generation), so completions of a closed descriptor give their buffers back to the ring and never reach a socket that reuses the number.ASYNC_CANCELandsubmit_and_wait).ReadSome()adapter: afterReadBuffer()on a socket,ReadSome()copies from the same queue of leases (onememcpy), so the order of bytes is kept and no single-shot read runs beside the multishot. The switch is a flag in the socket object; a socket that never calledReadBuffer()takes the old path plus one branch on that flag. The readiness backends are not touched.READ_MULTISHOT(the project minimum is 7.0) and liburing 2.5.Pool slots get one more cache line each: the ring hands the buffers out in turn, and 16 KiB apart they all fell into the same cache sets (N=16: L3 refills 1.05 -> 0.04 per hop, -6% cycles).
examples/benchgets-r some|buffer|adapter:ReadSome()as before (the same reader coroutine as on master),ReadBuffer(), orReadSome()after oneReadBuffer()switched the pipe to the leases.Tests
rpi5, Linux 7.3, Debug + ASan, head fa03c20:
test_read_buffer_*35/35.-ENOBUFS.A/B
rpi5 (Cortex-A76, Linux 7.3.0-1003-raspi, liburing 2.15, GCC 15.3, Release,
taskset -c 3). master 85489f0 vs this PR fa03c20.examples/bench -w 100000: 25 runs per invocation, µs/hop = p50 / hops.perf statcycles:u/cycles:k of-w 100000minus-w 100, per hop.single N=1024, uring, 7 repetitions:
single N=1024, epoll, 7 repetitions (
ReadBuffer()on epoll pays one moreread()with EAGAIN per hop than the bench'sReadSomeYield(), because it tries the read first likeReadSome()):single N=16, 5 repetitions:
chain100 N=1024 (
-a 100), 5 repetitions:Actor bench (
ping_actors, 10 nodes, inflight 1024, 10M messages, still onReadSome()), msg/s:Result
io_rw_init_file,aa_file_perm, the copy). Only the SQE, the first attempt with -EAGAIN and the apoll arm go away, and buffer selection is added.ReadBuffer()) and -10.9% (adapter).ReadSome()adapter the TUring default. It costs 16 MiB per poller and gains nothing at N=1024.ReadBuffer()is opt-in. The user-side cost is the subject of a separate follow-up PR.