net: append ":53" to DNS servers when reading resolv.conf

Avoids generating some redundant garbage from re-concatenating the
same string for every DNS query.

benchmark                                      old allocs     new allocs     delta
BenchmarkGoLookupIP-32                         156            154            -1.28%
BenchmarkGoLookupIPNoSuchHost-32               456            446            -2.19%
BenchmarkGoLookupIPWithBrokenNameServer-32     577            564            -2.25%

benchmark                                      old bytes     new bytes     delta
BenchmarkGoLookupIP-32                         10873         10824         -0.45%
BenchmarkGoLookupIPNoSuchHost-32               43303         43140         -0.38%
BenchmarkGoLookupIPWithBrokenNameServer-32     46824         46616         -0.44%

Update #15473.

Change-Id: I3b0173dfedf31bd08eaea1069968b416850864a1
Reviewed-on: https://go-review.googlesource.com/22556
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Matthew Dempsky 2016-04-28 11:15:44 -07:00
parent 2cc27a7de9
commit 4d9bda51ff
4 changed files with 10 additions and 11 deletions

View file

@ -221,7 +221,7 @@ var updateResolvConfTests = []struct {
{
name: "golang.org",
lines: []string{"nameserver 8.8.8.8"},
servers: []string{"8.8.8.8"},
servers: []string{"8.8.8.8:53"},
},
{
name: "",
@ -231,7 +231,7 @@ var updateResolvConfTests = []struct {
{
name: "www.example.com",
lines: []string{"nameserver 8.8.4.4"},
servers: []string{"8.8.4.4"},
servers: []string{"8.8.4.4:53"},
},
}