net: ensure identical queries are not sent multiple times in builtin stub resolver

Prevents non-rooted queries with > ndots dots from being tried twice on error.
Fixes #8616.

Benchmark results on linux/amd64
benchmark                        old ns/op    new ns/op    delta
BenchmarkGoLookupIPNoSuchHost      8212394      4413293  -46.26%

benchmark                       old allocs   new allocs    delta
BenchmarkGoLookupIPNoSuchHost          216          108  -50.00%

benchmark                        old bytes    new bytes    delta
BenchmarkGoLookupIPNoSuchHost        17460         8726  -50.02%

LGTM=iant, mikioh.mikioh
R=golang-codereviews, iant, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/137870043
This commit is contained in:
Alex A Skinner 2014-08-30 07:50:50 +09:00 committed by Mikio Hara
parent 858c57f5bd
commit 854dbb7fdc
2 changed files with 15 additions and 12 deletions

View file

@ -217,3 +217,9 @@ func TestReloadResolvConfChange(t *testing.T) {
r.SetConf("nameserver 8.8.4.4")
r.WantServers([]string{"[8.8.4.4]"})
}
func BenchmarkGoLookupIPNoSuchHost(b *testing.B) {
for i := 0; i < b.N; i++ {
goLookupIP("some.nonexistent")
}
}