]> granicus.if.org Git - pdns/commitdiff
enable cache cleaner to clean some caches more agressively, plus make pdns use this...
authorBert Hubert <bert.hubert@netherlabs.nl>
Sat, 11 Sep 2010 13:40:03 +0000 (13:40 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Sat, 11 Sep 2010 13:40:03 +0000 (13:40 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1712 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/cachecleaner.hh
pdns/pdns_recursor.cc

index defd3a4a7d76149ae6c6695b9de8bf7dd15f0142..60ae08f27bfcb19c8f5339718781a40760df10e4 100644 (file)
@@ -4,7 +4,7 @@
 // this function can clean any cache that has a getTTD() method on its entries, and a 'sequence' index as its second index
 // the ritual is that the oldest entries are in *front* of the sequence collection, so on a hit, move an item to the end
 // on a miss, move it to the beginning
-template <typename T> void pruneCollection(T& collection, unsigned int maxCached)
+template <typename T> void pruneCollection(T& collection, unsigned int maxCached, unsigned int scanFraction=1000)
 {
   uint32_t now=(uint32_t)time(0);
   unsigned int toTrim=0;
@@ -22,12 +22,13 @@ template <typename T> void pruneCollection(T& collection, unsigned int maxCached
 
   unsigned int tried=0, lookAt, erased=0;
 
-  // two modes - if toTrim is 0, just look through 10000 records and nuke everything that is expired
+  // two modes - if toTrim is 0, just look through 1/scanFraction of all records 
+  // and nuke everything that is expired
   // otherwise, scan first 5*toTrim records, and stop once we've nuked enough
   if(toTrim)
     lookAt=5*toTrim;
   else
-    lookAt=cacheSize/1000;
+    lookAt=cacheSize/scanFraction;
 
   typename sequence_t::iterator iter=sidx.begin(), eiter;
   for(; iter != sidx.end() && tried < lookAt ; ++tried) {
index 2b2b36ed41ba61bd93b6f96ca97e9246f75e563e..537ee7bcacabf2bd4ca0f7d483ec1de68209c033 100644 (file)
@@ -1084,7 +1084,7 @@ try
   struct timeval now;
   Utility::gettimeofday(&now, 0);
 
-//  clog<<"* "<<t_id<<" "<<(void*)&last_stat<<"\t"<<(unsigned int)last_stat<<endl;
+  // clog<<"* "<<t_id<<" "<<(void*)&last_stat<<"\t"<<(unsigned int)last_stat<<endl;
 
   if(now.tv_sec - last_prune > (time_t)(5 + t_id)) { 
     DTime dt;
@@ -1092,7 +1092,7 @@ try
     t_RC->doPrune(); // this function is local to a thread, so fine anyhow
     t_packetCache->doPruneTo(::arg().asNum("max-packetcache-entries") / g_numThreads);
     
-    pruneCollection(t_sstorage->negcache, ::arg().asNum("max-cache-entries") / (g_numThreads * 5));
+    pruneCollection(t_sstorage->negcache, ::arg().asNum("max-cache-entries") / (g_numThreads * 10), 200);
     
     if(!((cleanCounter++)%40)) {  // this is a full scan!
       time_t limit=now.tv_sec-300;