diff options
author | 2018-05-01 21:04:06 +0100 | |
---|---|---|
committer | 2018-05-01 21:04:06 +0100 | |
commit | 5735292406caf7d490853cee37f12126a8b7a4dc (patch) | |
tree | 119996d193d3cbf893992ad9b9ddfbba4caf342c /plugin/etcd | |
parent | c48531bb35fa1bb5f9e41a00d98794ea1978f01e (diff) | |
download | coredns-5735292406caf7d490853cee37f12126a8b7a4dc.tar.gz coredns-5735292406caf7d490853cee37f12126a8b7a4dc.tar.zst coredns-5735292406caf7d490853cee37f12126a8b7a4dc.zip |
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
Diffstat (limited to 'plugin/etcd')
-rw-r--r-- | plugin/etcd/handler.go | 3 | ||||
-rw-r--r-- | plugin/etcd/stub_handler.go | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/plugin/etcd/handler.go b/plugin/etcd/handler.go index ebd73d946..f69fdad00 100644 --- a/plugin/etcd/handler.go +++ b/plugin/etcd/handler.go @@ -84,10 +84,11 @@ func (e *Etcd) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) ( m := new(dns.Msg) m.SetReply(r) - m.Authoritative, m.RecursionAvailable, m.Compress = true, true, true + m.Authoritative, m.RecursionAvailable = true, true 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) m, _ = state.Scrub(m) diff --git a/plugin/etcd/stub_handler.go b/plugin/etcd/stub_handler.go index ac533f810..300e0a350 100644 --- a/plugin/etcd/stub_handler.go +++ b/plugin/etcd/stub_handler.go @@ -32,8 +32,9 @@ func (s Stub) ServeDNS(ctx context.Context, w dns.ResponseWriter, req *dns.Msg) if e != nil { return dns.RcodeServerFailure, e } - m.RecursionAvailable, m.Compress = true, true + m.RecursionAvailable = true state.SizeAndDo(m) + m, _ = state.Scrub(m) w.WriteMsg(m) return dns.RcodeSuccess, nil } |