PowerDNS/pdns — pull request #1139 by mzealey (2013-12-02 09:54:36+00:00)
Title: fixes PowerDNS/pdns#654

Running tests with query cache shows a massive performance drop. For a certain backend (all compiled with -pg for gprof profiling), with 1 reciever/backend thread running over random entries for a subdomain, I get:

No cache: 3500qps
Cache & negcache enabled: 450qps

Looking at the gprof output this is all because you are iterating the packetcache with a the CIBackwardsStringCompare function. The following patch changes packetcache to be stored reversed and provides a speedup to around 2500qps when enabled ie 5* performance improvement over existing packetcache.

I've not updated the purge(match) function as I can't quite figure out how it's meant to work at the moment but I don't imagine that's too hard. I've also not fully tested this patch only verified the performance improvements. Because the cache still has a ~25% performance hit we probably won't be able to use it.