net/dns/resolver: allow an extra alloc for go closure allocation

Go 1.17 switches to a register ABI on amd64 platforms.
Part of that switch is that go and defer calls use an argument-less
closure, which allocates. This means that we have an extra
alloc in some DNS work. That's unfortunate but not a showstopper,
and I don't see a clear path to fixing it.
The other performance benefits from the register ABI will all
but certainly outweigh this extra alloc.

Fixes #2545

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
josh/debug-flake
Josh Bleecher Snyder 3 years ago committed by Josh Bleecher Snyder
parent b6179b9e83
commit 881bb8bcdc

@ -931,8 +931,11 @@ func TestAllocs(t *testing.T) {
query []byte query []byte
want int want int
}{ }{
// Name lowercasing and response slice created by dns.NewBuilder. // Name lowercasing, response slice created by dns.NewBuilder,
{"forward", dnspacket("test1.ipn.dev.", dns.TypeA, noEdns), 2}, // and closure allocation from go call.
// (Closure allocation only happens when using new register ABI,
// which is amd64 with Go 1.17, and probably more platforms later.)
{"forward", dnspacket("test1.ipn.dev.", dns.TypeA, noEdns), 3},
// 3 extra allocs in rdnsNameToIPv4 and one in marshalPTRRecord (dns.NewName). // 3 extra allocs in rdnsNameToIPv4 and one in marshalPTRRecord (dns.NewName).
{"reverse", dnspacket("4.3.2.1.in-addr.arpa.", dns.TypePTR, noEdns), 5}, {"reverse", dnspacket("4.3.2.1.in-addr.arpa.", dns.TypePTR, noEdns), 5},
} }

Loading…
Cancel
Save