Changeset 1507

Show
Ignore:
Timestamp:
02/06/10 13:20:31 (3 years ago)
Author:
ahu
Message:

do far more frequent cache cleaning, and less 'cache scanning'. Thanks to Winfried Angele for experimenting with best settings.
scale caches with number of threads - so '1000000' cache entries and 4 threads will give you 250000 entries per thread

Location:
trunk/pdns/pdns
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/pdns_recursor.cc

    r1505 r1507  
    113113__thread MT_t* MT; // the big MTasker 
    114114 
     115unsigned int g_numThreads; 
     116 
    115117#define LOCAL_NETS "127.0.0.0/8, 10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12, ::1/128, fe80::/10" 
    116118 
     
    10571059  Utility::gettimeofday(&now, 0); 
    10581060 
    1059   if(now.tv_sec - last_prune > (time_t)(300 + 3*t_id)) {  
     1061  if(now.tv_sec - last_prune > (time_t)(5 + t_id)) {  
    10601062    DTime dt; 
    10611063    dt.setTimeval(now); 
    10621064    t_RC->doPrune(); // this function is local to a thread, so fine anyhow 
    1063     t_packetCache->doPruneTo(::arg().asNum("max-packetcache-entries")); 
     1065    t_packetCache->doPruneTo(::arg().asNum("max-packetcache-entries") / g_numThreads); 
    10641066     
    10651067    typedef SyncRes::negcache_t::nth_index<1>::type negcache_by_ttd_index_t; 
     
    11081110void makeThreadPipes() 
    11091111{ 
    1110   int numThreads = ::arg().asNum("threads"); 
    1111   for(int n=0; n < numThreads; ++n) { 
     1112  for(unsigned int n=0; n < g_numThreads; ++n) { 
    11121113    struct ThreadPipeSet tps; 
    11131114    int fd[2]; 
     
    16551656  g_maxMThreads=::arg().asNum("max-mthreads"); 
    16561657   
    1657   int numThreads = ::arg().asNum("threads"); 
    1658   if(numThreads == 1) { 
     1658  g_numThreads = ::arg().asNum("threads"); 
     1659  if(g_numThreads == 1) { 
    16591660    L<<Logger::Warning<<"Operating unthreaded"<<endl; 
    16601661    recursorThread(0); 
     
    16621663  else { 
    16631664    pthread_t tid; 
    1664     L<<Logger::Warning<<"Launching "<< numThreads <<" threads"<<endl; 
    1665     for(int n=0; n < numThreads; ++n) { 
     1665    L<<Logger::Warning<<"Launching "<< g_numThreads <<" threads"<<endl; 
     1666    for(unsigned int n=0; n < g_numThreads; ++n) { 
    16661667      pthread_create(&tid, 0, recursorThread, (void*)n); 
    16671668    } 
  • trunk/pdns/pdns/recursor_cache.cc

    r1501 r1507  
    359359  d_cachecachevalid=false; 
    360360 
    361   unsigned int maxCached=::arg().asNum("max-cache-entries"); 
     361  unsigned int maxCached=::arg().asNum("max-cache-entries") / g_numThreads; 
    362362  unsigned int toTrim=0; 
    363363   
     
    367367    toTrim = cacheSize - maxCached; 
    368368  } 
    369  
     369   
    370370  //  cout<<"Need to trim "<<toTrim<<" from cache to meet target!\n"; 
    371371 
     
    375375  unsigned int tried=0, lookAt, erased=0; 
    376376 
    377   // two modes - if toTrim is 0, just look through 10000 records and nuke everything that is expired 
     377  // two modes - if toTrim is 0, just look through 0.1% of all records and nuke everything that is expired 
    378378  // otherwise, scan first 5*toTrim records, and stop once we've nuked enough 
    379379  if(toTrim) 
    380380    lookAt=5*toTrim; 
    381381  else 
    382     lookAt=cacheSize/10; 
    383  
     382    lookAt=cacheSize/1000; 
    384383 
    385384  sequence_t::iterator iter=sidx.begin(), eiter; 
  • trunk/pdns/pdns/syncres.hh

    r1505 r1507  
    497497void parseACLs(); 
    498498extern RecursorStats g_stats; 
    499  
     499extern unsigned int g_numThreads; 
    500500 
    501501template<typename Index>