From 1df865a5802da860c7e50cbefb1e7024e9d0eadc Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Wed, 27 Oct 2021 16:03:18 -0700 Subject: [PATCH] wgengine/magicsock: allow even fewer allocs per UDP receive We improved things again for Go 1.18. Lock that in. Signed-off-by: Josh Bleecher Snyder --- wgengine/magicsock/magicsock_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/wgengine/magicsock/magicsock_test.go b/wgengine/magicsock/magicsock_test.go index 6c2a8f7b8..00d93477f 100644 --- a/wgengine/magicsock/magicsock_test.go +++ b/wgengine/magicsock/magicsock_test.go @@ -1341,11 +1341,15 @@ func TestReceiveFromAllocs(t *testing.T) { t.Skip("alloc tests are unreliable with -race") } // Go 1.16 and before: allow 3 allocs. - // Go Tailscale fork, Go 1.17+: only allow 2 allocs. + // Go 1.17: allow 2 allocs. + // Go Tailscale fork, Go 1.18+: allow 1 alloc. major, ts := goMajorVersion(runtime.Version()) maxAllocs := 3 - if major >= 17 || ts { + switch { + case major == 17: maxAllocs = 2 + case major >= 18, ts: + maxAllocs = 1 } t.Logf("allowing %d allocs for Go version %q", maxAllocs, runtime.Version()) roundTrip := setUpReceiveFrom(t)