Repository navigation
Conversation
This was referenced Nov 16, 2026
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.
Experiment 3 of the TUring write-path series (draft, for measurement; the owner decides).
Problem
On TUring every
WriteSome()is its own SQE, CQE and coroutine wake-up, even when the socket or pipe has room and the write would finish at once. The profile on rpi5 (single N=1024, master 85489f0) puts the write path at ~41% of the uring cycles per hop; ~660 cycles/hop of it are uring-only: the CQE post and request free, the write's share of SQE prep andfget, and the user side.Change
TUring::Write()andTUring::Send()first try the write directly:Send():send(fd, buf, n, MSG_DONTWAIT | MSG_NOSIGNAL).IORING_OP_SENDnever raises SIGPIPE either.Write():pwritev2(fd, iov, 1, -1, RWF_NOWAIT). RWF_NOWAIT gives EAGAIN on a full pipe even if the pipe is blocking, so the loop never blocks. A regular file returns EOPNOTSUPP (ext4 and tmpfs, checked on rpi5). Then the descriptor is written through the ring until the poller closes it, so a file write costs no extra syscall.op.Handleis reset, the result is inop.Result, andawait_suspend()ofTPollerDrivenSocket::WriteSome()/TPollerDrivenFileHandle::WriteSome()returns false, so the coroutine goes on without suspending. TIOCp never resets the handle here, so it does not change.TOperationState::Write).send()after a reset returns ECONNRESET first, then EPIPE. On master the ring gives the same; the new test passes on master too.IORING_OP_SENDwithout MSG_WAITALL. The rest is not posted to the ring.Tests
New, in
tests/tests.cpp:test_uring_write_at_once: socket and pipe writes finish insideWriteSome().test_uring_write_behind_queued_write: a write queued in the ring after EAGAIN, then room comes, then a 1-byte write. The 1-byte write must queue behind, and the stream must be the queued bytes, thenb.test_uring_write_stream_order: 4 MiB of counters through a 4 KiB SO_SNDBUF, with direct, partial and ring writes mixed, arrives in order.test_uring_write_at_once_errors: EPIPE without SIGPIPE fromSend(); ECONNRESET, then EPIPE, after an RST.test_uring_write_at_once_after_close: close while a write is pending gives -ECANCELED. Neither the pending-write count nor the regular-file mark stays on the number for the next file.test_uring_writeandtest_uring_write_resumeare updated: the first now checks the direct path, the second fills the pipe so the write still goes through the ring and resumes the coroutine.Mutations, each caught by its test: ignore pending writes →
behind_queued_write; no write-count decrement →after_close; no mark reset on close →after_close; no MSG_NOSIGNAL →errors; ring on any error →errors; full size as the result →stream_order.A/B (rpi5)
rpi5 (Cortex-A76, Linux 7.3.0-1003-raspi, liburing 2.15, GCC 15.3), Release,
examples/benchontaskset -c 3, run withrun_ab.sh. The configs alternate in each repetition. Values are the median (min-max) of 7 repetitions for single N=1024 and of 5 for N=16 and chain100 (-n 1024 -a 100). Cycles/hop = cycles:u + cycles:k of-w 100000minus-w 100, divided by 25 * 99900 hops. µs/hop = p50 of a run / 100001.On top of the deferred task work (#214): 0.970 / 0.976 / 1.049 of master in run 1, against 0.933 / 0.898 / 1.014 for #214 alone. Run 2, with the final #214: 0.978 / 0.992 / 1.052 against 0.933 / 0.903 / 0.983.
Result: slower on rpi5 (+2% / +4% / +10%):
write()/send()syscall per write costs more here (~500 cycles of syscall entry/exit on this kernel) than the write's SQE and CQE inside the sharedio_uring_enter.kqueue (Mac, M5 Pro, 7 repetitions): master 0.622 / 0.615 / 0.463 µs/hop, the combination with this change 0.622 / 0.614 / 0.463 (1.000 / 0.998 / 1.001). The readiness pollers do not use this code.
Checks
test_uring*23/23.test_uring_write_at_once*).