diff options
author | 2018-10-29 15:13:39 +0000 | |
---|---|---|
committer | 2018-10-29 08:13:39 -0700 | |
commit | e6d02a3fd25831fc68e5c6f2bf9b779098ef8b98 (patch) | |
tree | 305823ab8d1ba4e0e156209367cc4d201cd59c87 /plugin/cache/cache_test.go | |
parent | 29f42053643325bf0c23ae8da47362ea1a7650e0 (diff) | |
download | coredns-e6d02a3fd25831fc68e5c6f2bf9b779098ef8b98.tar.gz coredns-e6d02a3fd25831fc68e5c6f2bf9b779098ef8b98.tar.zst coredns-e6d02a3fd25831fc68e5c6f2bf9b779098ef8b98.zip |
cache: some optimizations (#2247)
Remove some optimization and lowercasing of the qname (in the end
miekg/dns should provide a fast and OK function for it).
* remove the make([]byte, 2) allocation in the key()
* use already lowercased qname in hash key calculation.
% benchcmp old.txt new.txt
benchmark old ns/op new ns/op delta
BenchmarkCacheResponse-4 9599 8735 -9.00%
Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'plugin/cache/cache_test.go')
-rw-r--r-- | plugin/cache/cache_test.go | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/plugin/cache/cache_test.go b/plugin/cache/cache_test.go index 6ef8c8c3a..4b71e9122 100644 --- a/plugin/cache/cache_test.go +++ b/plugin/cache/cache_test.go @@ -167,7 +167,7 @@ func TestCache(t *testing.T) { state := request.Request{W: nil, Req: m} mt, _ := response.Typify(m, utc) - valid, k := key(m, mt, state.Do()) + valid, k := key(state.Name(), m, mt, state.Do()) if valid { crr.set(m, k, mt, c.pttl) @@ -241,8 +241,7 @@ func BenchmarkCacheResponse(b *testing.B) { for i := 0; i < b.N; i++ { req := reqs[j] c.ServeDNS(ctx, &test.ResponseWriter{}, req) - j++ - j = j % 5 + j = (j + 1) % 5 } } |