Do Compress only when need in request.Scrub (#1760)

* Remove Compress by default

Set Compress = true in Scrub only when the message doesn not fit the
advertized buffer. Doing compression is expensive, so try to avoid it.

Master vs this branch
pkg: github.com/coredns/coredns/plugin/cache
BenchmarkCacheResponse-2   	   50000	     24774 ns/op

pkg: github.com/coredns/coredns/plugin/cache
BenchmarkCacheResponse-2   	  100000	     21960 ns/op

* and make it compile
This commit is contained in:
Miek Gieben 2018-05-01 21:04:06 +01:00 committed by GitHub
parent c48531bb35
commit 5735292406
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 27 additions and 23 deletions

View file

@ -17,7 +17,7 @@ func (k Kubernetes) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.M
m := new(dns.Msg)
m.SetReply(r)
m.Authoritative, m.RecursionAvailable, m.Compress = true, true, true
m.Authoritative, m.RecursionAvailable = true, true
zone := plugin.Zones(k.Zones).Matches(state.Name())
if zone == "" {
@ -79,6 +79,7 @@ func (k Kubernetes) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.M
m.Answer = append(m.Answer, records...)
m.Extra = append(m.Extra, extra...)
// TODO(miek): get rid of this by not adding dups in the first place, dnsutil.Append()?
m = dnsutil.Dedup(m)
state.SizeAndDo(m)