Repository navigation
epoll backend: per-fd completion delivery, two-buffer readv, no hold limit - #32
Merged
Merged
Conversation
…limit Profiling the epoll backend against the hand-written epoll server in bench/ (same syscalls per request, but 0.64-0.81x throughput) found: - It read every fd of an epoll_wait batch before running any completion, so the first connection's reply waited for all the other reads: with request/response traffic that costs throughput, and the server even idled. Completions now run after each fd's events. - A message that exactly fills a buffer cost a second read returning EAGAIN (2 reads per request at 16KB). recv now uses readv into two buffers: an empty second buffer means the socket is drained, and two full ones mean more data is waiting. - In-place sends were limited to half the buffers, as for io_uring, so at 512 connections later replies were copied (5% memmove). The epoll pool is ours and sends usually complete in the same iteration, so all buffers may now be held. Against the hand-written loop (server on 1 core, 16 scenarios): median 0.83x -> 0.94x; small messages at 16-64 connections 0.71-0.81x -> 0.92-0.99x; pipelined 16KB 0.96-1.14x -> 1.22-1.62x. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #32 +/- ##
==========================================
+ Coverage 70.27% 70.44% +0.16%
==========================================
Files 25 25
Lines 2335 2355 +20
==========================================
+ Hits 1641 1659 +18
- Misses 694 696 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
The epoll backend issued the same syscalls per request as the hand-written epoll server in
bench/but reached only 0.64–0.81x of its throughput. Profiling (perf, syscall tracepoints) found three causes:epoll_waitbatch (~20) before running any completion, so the first reply waited for all other reads. With request/response traffic that costs throughput — the server even idled ~5%. Completions now run after each fd's events (still after the submitting call returns, as with io_uring).readvinto two buffers: an empty second buffer means drained; two full ones mean more is waiting. (Reading only once per event fixed this but hurt pipelined 16KB by ~20%, so it was not kept.)Throughput vs the hand-written loop (server on 1 core, 16 scenarios, 3 rounds):
The whole suite passes on both backends (
-race), plus stress/fuzz seeds 3×; staticcheck clean. README, architecture doc and changelog (Unreleased) updated.🤖 Generated with Claude Code