Files
tailscale/kernel/linux/scripts/subnetbench.sh
T
Brad Fitzpatrick df191a1199 kernel/linux/{scripts,DESIGN.md}: add the subnet router benchmark and its results
subnetbench.sh runs tailscale.com's TestLeanSubnetRouter on the EC2
instances for each router CPU count given. ec2.sh now turns off source
and destination checks on its instances, so that one can forward as a
subnet router does, and installs nftables (for the router's masquerade).

DESIGN.md records the results: with 4 clients, tswg as the subnet
router forwards 2.1x (4 CPUs) to 3.2x (8 CPUs) what wireguard-go does,
which uses about 3 CPUs however many it has, at the least CPU per byte
of any tunnel, and reaches the 25 Gbps link at 16 CPUs. Zero-copy
receive was tried there and was 7% worse, so isn't in.

Updates #426

Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: I6b1da8bb8eaa17f9b20cbe36896426411b8b905f
2026-11-07 18:02:37 +00:00

35 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
#
# subnetbench.sh runs tailscale.com's TestLeanSubnetRouter (a subnet router
# with many clients and flows; see tstest/tswgbench/subnet_test.go) on the
# EC2 instances from ec2.sh, once for each router CPU count given, and
# prints the medians. Logs go to $TSWG_SUBNET_LOGS (default /tmp/subnetbench).
#
# Environment (see subnet_test.go for more):
# TSWG_LEAN_SUBNET router data planes (default plain,tswg,wggo,kernelwg)
# TSWG_COMPARE_RUNS runs of each (default 3)
# TAILSCALE_DIR the tailscale.com checkout (default ~/src/tailscale.com-tswg)
#
# usage: subnetbench.sh [ROUTER_CPUS...] (default: all of the router's CPUs)
set -eu
top=$(cd "$(dirname "$0")/.." && pwd)
ts=${TAILSCALE_DIR:-$HOME/src/tailscale.com-tswg}
logs=${TSWG_SUBNET_LOGS:-/tmp/subnetbench}
mkdir -p "$logs"
export TSWG_LEAN=1 TSWG_DIR="$top"
export TSWG_REMOTE="${TSWG_REMOTE:-$HOME/.cache/tslinux/ec2/hosts.json}"
export TSWG_LEAN_SUBNET="${TSWG_LEAN_SUBNET:-plain,tswg,wggo,kernelwg}"
export TSWG_COMPARE_RUNS="${TSWG_COMPARE_RUNS:-3}"
cd "$ts"
[ $# -gt 0 ] || set -- 0
for cpus in "$@"; do
echo "== router CPUs: $cpus (0 is all)" >&2
TSWG_SUBNET_ROUTER_CPUS=$cpus go test -count=1 ./tstest/tswgbench/ \
-run 'TestLeanSubnetRouter$' -v -timeout=60m > "$logs/cpus$cpus.log" 2>&1 || true
grep -E -e '--- FAIL|router .* CPUs|median|kernel reported' "$logs/cpus$cpus.log" |
sed 's/^ *[a-z_]*_test.go:[0-9]*: //'
done