C++23 / Linux io_uring / Zero-Copy
Bare-Metal Network Programming in C++
Building Zero-Copy io_uring Servers with Coroutine Scheduling and Registered Buffer Pools
Contents
- Copyright
- About the Author
- Preface
-
01Anatomy of a High-Performance Server
- 1.1The Request Lifecycle from NIC to Response
- 1.2Where Time Goes: System Calls, Copies, Context Switches, and Wakeups
- 1.3Concurrency Models: Thread-per-Connection, Reactor, Proactor, and Thread-per-Core
- 1.4Reference Server Architecture
Throughput and Tail Latency Ledger: Chapter 1
-
02The Linux Networking Stack
- 2.1NIC Queues, Interrupts, NAPI, and Socket Buffers
- 2.2TCP Behavior That Matters: Nagle, Delayed ACK, Congestion Control, and TIME_WAIT
- 2.3Socket Options: SO_REUSEPORT, TCP_NODELAY, and Buffer Sizing
- 2.4Multiqueue Scaling with RSS, RPS, and XPS
Throughput and Tail Latency Ledger: Chapter 2
-
03From epoll to io_uring
- 3.1Blocking, Non-Blocking, and Readiness-Based I/O
- 3.2epoll Edge-Triggered vs. Level-Triggered and Its Limits
- 3.3io_uring Architecture: Submission and Completion Rings
- 3.4Why Completion-Based I/O Changes Server Design
Throughput and Tail Latency Ledger: Chapter 3
-
04io_uring Fundamentals
- 4.1Ring Setup and the SQE and CQE Lifecycle
- 4.2Accept, Receive, and Send Operations
- 4.3Multishot Accept and Multishot Receive
- 4.4Ring Modes and Flags: SQPOLL, DEFER_TASKRUN, and SINGLE_ISSUER
Throughput and Tail Latency Ledger: Chapter 4
-
05Registered Resources and Buffer Pools
- 5.1Registered Files
- 5.2Registered Buffers
- 5.3Provided Buffer Rings
- 5.4Designing Registered Buffer Pools for Real Workloads
Throughput and Tail Latency Ledger: Chapter 5
-
06Zero-Copy I/O
- 6.1The Real Cost of Copying Data
- 6.2Zero-Copy Send and Completion Notifications
- 6.3splice, sendfile, and MSG_ZEROCOPY
- 6.4Zero-Copy Receive and Its Constraints
Throughput and Tail Latency Ledger: Chapter 6
-
07Coroutine Machinery for I/O
- 7.1Promise Types and Awaiters for I/O Operations
- 7.2Wrapping io_uring Operations as Awaitables
- 7.3Task Types and Return Value Propagation
- 7.4Coroutine Frame Allocation and Custom Allocators
Throughput and Tail Latency Ledger: Chapter 7
-
08Coroutine Scheduling
- 8.1Building the Event Loop
- 8.2Thread-per-Core Executors
- 8.3Cross-Thread Wakeups with eventfd and msg_ring
- 8.4Cancellation, Timeouts, and Linked Operations
Throughput and Tail Latency Ledger: Chapter 8
-
09Lifetime and Ownership Across Suspension
- 9.1Buffer Ownership Across Suspension Points
- 9.2Dangling References in Coroutines
- 9.3Structured Concurrency and Task Groups
- 9.4Integrating with std::execution Senders and Receivers
Throughput and Tail Latency Ledger: Chapter 9
-
10Protocol Parsing
- 10.1Framing: Length-Prefixed, Delimited, and Streaming Protocols
- 10.2A Zero-Copy HTTP/1.1 Parser
- 10.3Pipelining and Request Ordering
- 10.4Incremental Parsing Without Allocation
Throughput and Tail Latency Ledger: Chapter 10
-
11TLS and Connection Security
- 11.1TLS in an Asynchronous Server
- 11.2Kernel TLS Offload
- 11.3Handshake Cost and Session Resumption
- 11.4Defending Against Slowloris and Resource Exhaustion
Throughput and Tail Latency Ledger: Chapter 11
-
12UDP and Datagram Servers
- 12.1High-Throughput UDP Servers
- 12.2Batching with recvmmsg, sendmmsg, GSO, and GRO
- 12.3Multicast Reception and Transmission
- 12.4QUIC Design Considerations
Throughput and Tail Latency Ledger: Chapter 12
-
13Backpressure and Flow Control
- 13.1Bounded Queues and Backpressure Propagation
- 13.2Admission Control and Load Shedding
- 13.3Connection Limits and Accept Throttling
- 13.4Per-Connection Memory Budgets
Throughput and Tail Latency Ledger: Chapter 13
-
14Tail Latency and Scaling
- 14.1Thread-per-Core with SO_REUSEPORT, CPU Pinning, and NUMA Awareness
- 14.2Batching vs. Latency Trade-Offs
- 14.3Load Testing with wrk2 and Avoiding Coordinated Omission
- 14.4When io_uring Is Not Enough: AF_XDP and DPDK
Throughput and Tail Latency Ledger: Chapter 14
-
15Running Network Servers in Production
- 15.1Graceful Shutdown, Connection Draining, and Zero-Downtime Restarts
- 15.2Observability: Connection, Ring, and Latency Metrics
- 15.3Fault Injection with tc netem and Fuzzing Protocol Parsers
- 15.4Security Hardening: io_uring Restrictions, seccomp, and Deployment
Throughput and Tail Latency Ledger: Chapter 15
- Aio_uring Operation and Flag Reference
- BSocket Options and Kernel Tuning Reference
- CCoroutine Awaitable Patterns Reference
- DServer Production Readiness Checklist