Files
tailscale/net
Kabir Sikand 5e2822f9b6 net/tstun: hoist the subnet route lookup table onto the Wrapper
Gating the packet path on subnetCountersActive() cost a second atomic load on
every packet, because it loaded the subnetCounters and then its table. Measured,
that doubled what a node with counting disabled pays: 0.375 -> 0.735 ns/op.

The subnetCounters must survive a disable, but the packet path never needs the
object itself, only the table. Publishing the table on the Wrapper puts the
gate back to one nil-able atomic load, and lets the hooks take a
*bart.Table[*routeCounters] and do the lookup directly.

linux/arm64, 5-route table, 2M iterations:

  disabled hook   0.375 -> 0.394 ns/op   0 allocs (parity)
  enabled hook     66.9 -> 64.8  ns/op   0 allocs

Updates tailscale/corp#45684

Change-Id: I8a4292268c0a78cdcf567720119bf144a3072bab
Signed-off-by: Kabir Sikand <[email protected]>
2026-07-29 17:56:58 +00:00
..
2026-07-10 17:39:16 -07:00