mirror of
https://github.com/coredns/coredns.git
synced 2025-11-18 01:42:17 -05:00
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:
@@ -75,7 +75,7 @@ func (h Handler) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
|
||||
|
||||
msg := new(dns.Msg)
|
||||
msg.SetReply(r)
|
||||
msg.Authoritative, msg.RecursionAvailable, msg.Compress = true, true, true
|
||||
msg.Authoritative, msg.RecursionAvailable = true, true
|
||||
msg.Rcode = template.rcode
|
||||
|
||||
for _, answer := range template.answer {
|
||||
@@ -105,6 +105,7 @@ func (h Handler) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
|
||||
}
|
||||
|
||||
state.SizeAndDo(msg)
|
||||
state.Scrub(msg)
|
||||
w.WriteMsg(msg)
|
||||
return template.rcode, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user