Repository navigation
Commit 400a05f
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
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
67 | | - | |
| 68 | + | |
0 commit comments