You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailscale/wgengine
Josh Bleecher Snyder 88586ec4a4 wgengine/magicsock: remove an alloc from ReceiveIPvN
We modified the standard net package to not allocate a *net.UDPAddr
during a call to (*net.UDPConn).ReadFromUDP if the caller's use
of the *net.UDPAddr does not cause it to escape.
That is https://golang.org/cl/291390.

This is the companion change to magicsock.
There are two changes required.
First, call ReadFromUDP instead of ReadFrom, if possible.
ReadFrom returns a net.Addr, which is an interface, which always allocates.
Second, reduce the lifetime of the returned *net.UDPAddr.
We do this by immediately converting it into a netaddr.IPPort.

We left the existing RebindingUDPConn.ReadFrom method in place,
as it is required to satisfy the net.PacketConn interface.

With the upstream change and both of these fixes in place,
we have removed one large allocation per packet received.

name           old time/op    new time/op    delta
ReceiveFrom-8    16.7µs ± 5%    16.4µs ± 8%     ~     (p=0.310 n=5+5)

name           old alloc/op   new alloc/op   delta
ReceiveFrom-8      112B ± 0%       64B ± 0%  -42.86%  (p=0.008 n=5+5)

name           old allocs/op  new allocs/op  delta
ReceiveFrom-8      3.00 ± 0%      2.00 ± 0%  -33.33%  (p=0.008 n=5+5)

Co-authored-by: Sonia Appasamy <sonia@tailscale.com>
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
5 years ago
..
filter wgengine/filter: add a Clone method. 5 years ago
magicsock wgengine/magicsock: remove an alloc from ReceiveIPvN 5 years ago
monitor wgengine/monitor: close closeHandle 5 years ago
netstack types/netmap: split controlclient.NetworkMap off into its own leaf package 5 years ago
router wgengine/router: fix BSD router to support multiple local addrs, IPv6 5 years ago
tsdns tstest: simplify goroutine leak tests 5 years ago
tstun wgengine/tstun: reply to MagicDNS pings 5 years ago
wgcfg types/netmap: split controlclient.NetworkMap off into its own leaf package 5 years ago
wglog wgengine: adapt to wireguard-go changes 5 years ago
winnet wgengine/winnet: don't build on non-windows 5 years ago
pendopen.go ipn: split LocalBackend off into new ipn/ipnlocal package 5 years ago
userspace.go wgengine: remove IpcGetOperation filter 5 years ago
userspace_test.go all: move wgcfg from wireguard-go 5 years ago
watchdog.go types/netmap: split controlclient.NetworkMap off into its own leaf package 5 years ago
watchdog_test.go cmd/tailscaled, wgengine/netstack: add start of gvisor userspace netstack work 5 years ago
wgengine.go types/netmap: split controlclient.NetworkMap off into its own leaf package 5 years ago