From 881bb8bcdc9563813e5713f3f7ec3c4195ffbfa7 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Thu, 29 Jul 2021 12:25:06 -0700 Subject: [PATCH] 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 --- net/dns/resolver/tsdns_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/dns/resolver/tsdns_test.go b/net/dns/resolver/tsdns_test.go index 353327b35..94f3eb88e 100644 --- a/net/dns/resolver/tsdns_test.go +++ b/net/dns/resolver/tsdns_test.go @@ -931,8 +931,11 @@ func TestAllocs(t *testing.T) { query []byte want int }{ - // Name lowercasing and response slice created by dns.NewBuilder. - {"forward", dnspacket("test1.ipn.dev.", dns.TypeA, noEdns), 2}, + // Name lowercasing, response slice created by dns.NewBuilder, + // 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). {"reverse", dnspacket("4.3.2.1.in-addr.arpa.", dns.TypePTR, noEdns), 5}, }