]> granicus.if.org Git - pdns/commit
rec: Add a NetmaskTree-based cache index for ECS entries
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 19 Jun 2017 10:51:39 +0000 (12:51 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 27 Jun 2017 12:37:59 +0000 (14:37 +0200)
commite74f866a076c7f9b6ea7c308dd53ab6f0c74dd36
tree8bfa55c1d4164d707fe3c7cdb1da1c346cecf9d3
parent732d246601a60b63e9f77ba63f463c10e563a780
rec: Add a NetmaskTree-based cache index for ECS entries

The main idea is not to have to go through all the netmask-specific
entries for a given (qname/qtype), but to have to know quickly which
netmask-specific entry is the best match.
To do that we add an index containing a NetmaskTree for each
(qname,qtype), and we then know quickly which entry to get from the
"regular" cache.

Initial benchmarking results:
 - inserting non-netmask-specific entries has the same performance ;
 - inserting netmask-specific entries is 40% slower because of the additional insertion ;
 - looking for a (qname/qtype) that has no netmask-specific entries remains the same ;
 - looking for (qname/qtype) with 65k netmask-specific entries but only matching the non-netmask one is around 2000 times faster ;
 - looking for (qname/qtype) with 65k netmask-specific entries and matching one is also around 2000 times faster ;
 - pruning the cache is a lot slower (from 11 millions/s to 1.8 millions/s)

Remaining issues:
 - ANY queries do not use the index ;
 - we have to do two lookups
 - removal is slower, but might still be good enough
 - NetmaskTree.erase() does not compact the tree.

Ideas that didn't seem to work out:
 - Storing a pointer of some kind in the NetmaskTree to save a lookup:
   caused issues with our generic cache management functions (moving
   entries to the front or to the back requires an iterator)
 - Keeping the NMT index in the empty Netmak entry (the non-netmask
   specific one) save the additional lookup when we have no ECS
   entries, but made cache management very awkward because we needed
   to keep the non-netmask specific entry around as a place holder
   for the ECS index even if it held no data.
pdns/cachecleaner.hh
pdns/dbdnsseckeeper.cc
pdns/dnsseckeeper.hh
pdns/recpacketcache.cc
pdns/recpacketcache.hh
pdns/recursor_cache.cc
pdns/recursor_cache.hh
pdns/recursordist/negcache.cc
pdns/recursordist/negcache.hh
pdns/syncres.cc