Skip to content

Commit 400a05f

Browse files
committed
tokio-quiche: batch UDP receives with URO on Windows
On Windows the router reads one datagram per receive call, so a fast download pays one system call and one wakeup per QUIC packet. Windows can merge consecutive datagrams of a flow into one receive (UDP receive offload, URO), but only for sockets that set UDP_RECV_MAX_COALESCED_SIZE, and the size of the merged datagrams is only reported in a UDP_COALESCED_INFO control message, which needs WSARecvMsg. On a Windows 11 Arm64 laptop a download received 33-36 datagrams per call with URO. SocketCapabilities::apply_all_and_get_compatibility() sets the option and reports it as has_gro, so URO is opt-in like Linux GRO, and listen() and apply_max_capabilities() turn it on. The router receives through WSARecvMsg and puts the reported segment size into the same `gro` field the Linux GRO path fills, so the IO worker and the client connector split the batch as they already do on Linux. WSARecvMsg is resolved for each socket, since the pointer belongs to that socket's Winsock provider. Some machines coalesce without attaching UDP_COALESCED_INFO, which turns a train of datagrams into one payload that can't be split (seen with WSL2 on Windows on Arm and with some NIC drivers), so quinn-udp leaves URO off by default. A receive larger than MAX_DATAGRAM_SIZE without a segment size that fits is treated as such a train: the router drops it and turns URO off for that socket. A single datagram that large is dropped the same way; it never fit the router's MAX_DATAGRAM_SIZE receive buffer. Linux and macOS are unchanged.
1 parent 5e1668d commit 400a05f

5 files changed

Lines changed: 795 additions & 200 deletions

File tree

‎tokio-quiche/src/quic/AGENTS.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ router/
2828
mod.rs # InboundPacketRouter: Future, demux by DCID, ConnectionMapCommand
2929
acceptor.rs # ConnectionAcceptor: server-side InitialPacketHandler (RETRY flow)
3030
connector.rs # ClientConnector: client-side InitialPacketHandler (handshake FSM)
31+
uro.rs # Windows UDP receive offload: WSARecvMsg receive, coalesced-size parsing
3132
```
3233

3334
## WHERE TO LOOK
@@ -64,4 +65,4 @@ router/
6465
- `ConnectionMap` uses `CidOwned::Optimized([u64; 3])` for v1 CIDs (<=20 bytes) to avoid heap allocation on lookup.
6566
- `InboundPacketRouter` implements `Future` directly (not async fn) -- polled as a spawned task.
6667
- `short_dcid()` fast-path extracts DCID from short header packets without full `Header::from_slice`.
67-
- Router tests are `#[cfg(all(test, unix))]` in `router/mod.rs` -- not Windows-compatible.
68+
- Router tests are `#[cfg(all(test, unix))]` in `router/mod.rs` -- not Windows-compatible. Windows router tests live in `router/uro.rs`.

0 commit comments

Comments
 (0)