Show
Ignore:
Timestamp:
06/13/10 22:45:28 (3 years ago)
Author:
ahu
Message:

comment the 'inflighter' a bit, plus add very nice statistical output to dnsbulktest
see  http://bert-hubert.blogspot.com/2010/06/better-statistical-regression-tests.html

Files:
1 modified

Legend:

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

    r1634 r1635  
    3131    d_init=true; 
    3232  } 
    33   void run(); 
     33   
     34  bool run(); //!< keep calling this as long as it returns 1, or if it throws an exception  
    3435   
    3536  unsigned int d_maxInFlight; 
     
    7879}; 
    7980 
    80 template<typename Container, typename SendReceive> void Inflighter<Container, SendReceive>::run() 
     81template<typename Container, typename SendReceive> bool Inflighter<Container, SendReceive>::run() 
    8182{ 
    8283  if(!d_init) 
    8384    init(); 
    8485     
    85   // cout << "Have "<<d_container.size() << " things to do!"<<endl; 
    86    
    8786  for(;;) { 
    8887    int burst = 0; 
     88 
     89    // 'send' as many items as allowed, limited by 'max in flight' and our burst parameter (which limits query rate growth) 
    8990    while(d_iter != d_container.end() && d_ttdWatch.size() < d_maxInFlight) {  
    9091      TTDItem ttdi; 
     
    9394      gettimeofday(&ttdi.ttd, 0); 
    9495      ttdi.ttd.tv_sec += d_timeoutSeconds; 
    95        
     96      if(d_ttdWatch.count(ttdi.id)) { 
     97//        cerr<<"DUPLICATE INSERT!"<<endl; 
     98      } 
    9699      d_ttdWatch.insert(ttdi); 
    97100       
     
    100103    } 
    101104    int processed=0; 
     105     
     106     
     107    // if there are queries in flight, handle responses 
    102108    if(!d_ttdWatch.empty()) { 
    103109      // cerr<<"Have "<< d_ttdWatch.size() <<" queries in flight"<<endl;             
     
    105111      typename SendReceive::Identifier id; 
    106112       
     113      // get as many answers as available - 'receive' should block for a short while to wait for an answer 
    107114      while(d_sr.receive(id, answer)) { 
    108         typename ttdwatch_t::iterator ival = d_ttdWatch.find(id); 
    109         if(ival != d_ttdWatch.end()) { 
     115        typename ttdwatch_t::iterator ival = d_ttdWatch.find(id); // match up what we received to what we were waiting for 
     116 
     117        if(ival != d_ttdWatch.end()) { // found something! 
    110118          ++processed; 
    111           // cerr<<"Received expected item with id '"<<id<<"' and value '"<<item<<"'"<<endl; 
    112           d_sr.deliverAnswer(*ival->iter, answer); 
     119          d_sr.deliverAnswer(*ival->iter, answer);    // deliver to sender/receiver 
    113120          d_ttdWatch.erase(ival); 
    114121          break; // we can send new questions! 
     
    121128     
    122129       
    123       if(!processed) { // no new responses, time for some cleanup 
     130      if(!processed /* || d_ttdWatch.size() > 10000 */ ) { // no new responses, time for some cleanup of the ttdWatch 
    124131        struct timeval now; 
    125132        gettimeofday(&now, 0); 
     
    128135        waiters_by_ttd_index_t& waiters_index = boost::multi_index::get<TimeTag>(d_ttdWatch); 
    129136 
     137        // this provides a list of items sorted by age 
    130138        for(typename waiters_by_ttd_index_t::iterator valiter = waiters_index.begin(); valiter != waiters_index.end(); ) { 
    131139          if(valiter->ttd.tv_sec < now.tv_sec || (valiter->ttd.tv_sec == now.tv_sec && valiter->ttd.tv_usec < now.tv_usec)) { 
     
    136144          } 
    137145          else  
    138             break; 
     146            break; // if this one was too new, rest will be too 
    139147        } 
    140148      } 
     
    143151      break; 
    144152  } 
     153  return false; 
    145154} 
    146155