Files
tailscale/kernel/linux
Brad Fitzpatrick 96695d4464 kernel/linux/src: scale a big host serving and crawling many peers
A 128-CPU host on the tailnet, serving HTTP-like responses to 37 peers
or crawling them all at once, was held back by three things, each fixed
here:

Sending by combining: a peer's encrypted packets went out from its tx
worker, one work item on one CPU at a time, which on a NIC without UDP
segmentation offload (EC2's ENA) also segments them, so the CPUs the
tx workers landed on ran at 90% and more. Now the encrypt worker that
makes an entry ready sends what's ready, in order, itself, unless
another CPU is sending the peer's (a trylock), which then sends it.

Local sockets' lone packets (TCP's ACKs, small requests) are encrypted
and sent inline, when nothing of the peer's is on its way through the
workers to be overtaken: a crawler spent 7% of its CPU on the encrypt
ring's lock for its ACKs.

Steering: with more peers than NIC queues, RSS puts several peers' UDP
flows on some CPUs, and receiving inline left those at 100% and the
rest idle. When a CPU is over rx_steer_busy (default 90%) busy, by its
idle time, or its softirq work runs out of budget, its peers' packets
go to each peer's home CPU (one not receiving from a NIC, by hash)
through a lockless per-CPU list and that CPU's NAPI: RPS, per peer, for
our packets, when needed. A peer changes between inline, steered and the
parallel way only when the way it was going is empty, so as not to
reorder.

On EC2 (c6in.32xlarge, 32 NIC queues, MTU 1280): serving goes from
84-98 to 133-137 Gbps (plain TCP without a tunnel: 152; wireguard-go:
5.5), at 3.9 CPU-s/GB, and crawling from 41-51 to 80-83 (plain: 128;
wireguard-go: 8.5), where the NIC's busiest queues, with two or three
peers each, are at ENA's limit of about 680k packets per second.

Updates #426

Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: I011ab98d61296b5beef172ae1581d463820179a5
2026-11-08 11:52:01 +00:00
..