Bläddra i källkod

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 <[email protected]>
Josh Bleecher Snyder 4 år sedan
förälder
incheckning
1df865a580
1 ändrade filer med 6 tillägg och 2 borttagningar
  1. 6 2
      wgengine/magicsock/magicsock_test.go

+ 6 - 2
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)