Changeset 535
- Timestamp:
- 11/02/05 15:27:31 (8 years ago)
- Location:
- trunk/pdns/pdns
- Files:
-
- 8 modified
-
Makefile.am (modified) (1 diff)
-
dnspbench.cc (modified) (2 diffs)
-
dnsreplay-mindex.cc (modified) (2 diffs)
-
pdns_recursor.cc (modified) (2 diffs)
-
recursor_cache.cc (modified) (1 diff)
-
recursor_cache.hh (modified) (1 diff)
-
syncres.cc (modified) (6 diffs)
-
syncres.hh (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/Makefile.am
r530 r535 48 48 49 49 dnspbench_SOURCES=dnspbench.cc sstuff.hh dnsparser.cc dnsparser.hh dnsrecords.cc dnswriter.cc dnswriter.hh \ 50 misc.cc misc.hh rcpgenerator.cc rcpgenerator.hh base64.cc base64.hh 50 misc.cc misc.hh rcpgenerator.cc rcpgenerator.hh base64.cc base64.hh unix_utility.cc logger.cc \ 51 statbag.cc 51 52 52 53 -
trunk/pdns/pdns/dnspbench.cc
r516 r535 4 4 #include "dnswriter.hh" 5 5 #include "dnsrecords.hh" 6 #include "logger.hh" 7 #include "statbag.hh" 6 8 9 Logger L("dnspbench"); 10 StatBag S; 7 11 8 12 … … 10 14 try 11 15 { 16 dnsheader dnsheader; 17 dnsheader.qdcount=htons(1); 18 dnsheader.ancount=htons(1); 19 Socket s(InterNetwork, Datagram); 20 string spacket; 21 char* p=(char*)&dnsheader; 22 spacket.assign(p, p+sizeof(dnsheader)); 23 IPEndpoint rem("127.0.0.1",5300); 24 s.sendTo(spacket, rem); 25 26 return 0; 27 12 28 reportAllTypes(); 13 29 14 cerr<<"sizeof(optString): "<<sizeof(struct optString)<<endl;30 vector<uint8_t> packet; 15 31 16 optString os("hallo!");17 18 cerr<<"optString: '"<<(string)os<<"'\n";19 20 vector<uint8_t> packet;21 22 32 uint16_t type=DNSRecordContent::TypeToNumber(argv[2]); 23 33 -
trunk/pdns/pdns/dnsreplay-mindex.cc
r527 r535 512 512 } 513 513 514 double factor= 20;514 double factor=10; 515 515 516 516 seconds/=factor; … … 624 624 gettimeofday(&now, 0); 625 625 626 mental_time= mental_time + 2*(now-then);626 mental_time= mental_time + 1*(now-then); 627 627 } 628 628 out:; -
trunk/pdns/pdns/pdns_recursor.cc
r533 r535 501 501 if(qcounter) { 502 502 L<<Logger::Error<<"stats: "<<qcounter<<" questions, "<<RC.size()<<" cache entries, "<<SyncRes::s_negcache.size()<<" negative entries, " 503 <<(int)((RC.cacheHits*100.0)/(RC.cacheHits+RC.cacheMisses))<<"% cache hits"; 504 L<<Logger::Error<<", outpacket/query ratio "<<(int)(SyncRes::s_outqueries*100.0/SyncRes::s_queries)<<"%"; 503 <<(int)((RC.cacheHits*100.0)/(RC.cacheHits+RC.cacheMisses))<<"% cache hits"<<endl; 504 L<<Logger::Error<<"stats: throttle map: "<<SyncRes::s_throttle.size()<<", ns speeds: "<<SyncRes::s_nsSpeeds.size()<<endl; 505 L<<Logger::Error<<"stats: outpacket/query ratio "<<(int)(SyncRes::s_outqueries*100.0/SyncRes::s_queries)<<"%"; 505 506 L<<Logger::Error<<", "<<(int)(SyncRes::s_throttledqueries*100.0/(SyncRes::s_outqueries+SyncRes::s_throttledqueries))<<"% throttled, " 506 507 <<SyncRes::s_nodelegated<<" no-delegation drops"<<endl; … … 519 520 if(now - last_prune > 60) { 520 521 RC.doPrune(); 522 int pruned=0; 523 for(map<string, NegCacheEntry>::iterator i = SyncRes::s_negcache.begin(); i != SyncRes::s_negcache.end();) 524 if(i->second.ttd > now) { 525 SyncRes::s_negcache.erase(i++); 526 pruned++; 527 } 528 else 529 ++i; 530 // cerr<<"Pruned "<<pruned<<" records, left "<<SyncRes::s_negcache.size()<<"\n"; 521 531 last_prune=time(0); 522 532 } -
trunk/pdns/pdns/recursor_cache.cc
r534 r535 59 59 } 60 60 61 /* the code below is rather tricky - it basically replaces the stuff cached for qname by content, but it is special 62 cased for when inserting identical records with only differing ttls, in which case the entry is not 63 touched, but only given a new ttd */ 61 64 void MemRecursorCache::replace(const string &qname, const QType& qt, const set<DNSResourceRecord>& content) 62 65 { 63 66 set<StoredRecord>& stored=d_cache[toLowerCanonic(qname)+"|"+qt.getName()]; 64 67 65 for(set<StoredRecord>::iterator k=stored.begin();k!=stored.end();++k) 66 k->d_string.prune(); 68 set<StoredRecord>::iterator k; 69 typedef vector<set<StoredRecord>::iterator> touched_t; 70 touched_t touched; 67 71 68 stored.clear(); 72 // walk through new content, encode it as new 73 StoredRecord dr; 69 74 70 75 for(set<DNSResourceRecord>::const_iterator i=content.begin(); i != content.end(); ++i) { 71 StoredRecord dr;72 76 dr.d_ttd=i->ttl; 73 77 dr.d_string=DNSRR2String(*i); 74 stored.insert(dr); 75 //cerr<<"Storing: "<< toLowerCanonic(qname)+"|"+qt.getName() << " <=> '"<<i->content<<"', ttd="<<i->ttl<<endl; 78 k=stored.find(dr); 79 if(k!=stored.end()) { // was it there already? 80 // cerr<<"updating record '"<<qname<<"' -> '"<<i->content<<"'\n"; 81 k->d_ttd=i->ttl; // update ttl 82 touched.push_back(k); // note that this record is here to stay 83 } 84 else { 85 // cerr<<"inserting record '"<<qname<<"' -> '"<<i->content<<"'\n"; 86 touched.push_back(stored.insert(dr).first); // same thing 87 } 88 } 89 90 for(k=stored.begin(); k!=stored.end(); ) { // walk over the stored set of records 91 touched_t::const_iterator j; 92 for(j=touched.begin(); j!=touched.end() && *j != k ; ++j); // walk over touched iterators 93 if(j==touched.end()) { // this record was not there 94 // DNSResourceRecord rr=String2DNSRR(qname, qt, k->d_string, 0); 95 // cerr<<"removing from record '"<<qname<<"' '"<<rr.content<<"'\n"; 96 k->d_string.prune(); 97 stored.erase(k++); // cleanup 98 } 99 else 100 ++k; 76 101 } 77 102 } -
trunk/pdns/pdns/recursor_cache.hh
r518 r535 72 72 struct StoredRecord 73 73 { 74 uint32_t d_ttd;74 mutable uint32_t d_ttd; 75 75 optString<> d_string; 76 76 bool operator<(const StoredRecord& rhs) const 77 77 { 78 return make_pair(d_ttd, d_string) < make_pair(rhs.d_ttd, rhs.d_string); 78 return d_string < rhs.d_string; 79 // return make_pair(d_ttd, d_string) < make_pair(rhs.d_ttd, rhs.d_string); 79 80 } 80 81 }; 81 82 typedef map<string, set<StoredRecord> > cache_t; 82 83 private: 83 84 cache_t d_cache; 84 85 }; -
trunk/pdns/pdns/syncres.cc
r521 r535 38 38 39 39 map<string,NegCacheEntry> SyncRes::s_negcache; 40 map<string,DecayingEwma> SyncRes::s_nsSpeeds; 40 41 unsigned int SyncRes::s_queries; 41 42 unsigned int SyncRes::s_outgoingtimeouts; … … 230 231 sqname=ni->second.name; 231 232 sqt="SOA"; 232 233 233 } 234 234 else { … … 305 305 } 306 306 307 static map<string,DecayingEwma> nsSpeeds; 307 308 308 309 309 struct speedOrder … … 325 325 for(set<string>::const_iterator i=nameservers.begin();i!=nameservers.end();++i) { 326 326 rnameservers.push_back(*i); 327 DecayingEwma& temp= nsSpeeds[toLower(*i)];327 DecayingEwma& temp=s_nsSpeeds[toLower(*i)]; 328 328 speeds[*i]=temp.get(&d_now); 329 329 } … … 406 406 LOG<<prefix<<qname<<": error resolving"<<endl; 407 407 408 nsSpeeds[toLower(*tns)].submit(1000000, &d_now); // 1 sec408 s_nsSpeeds[toLower(*tns)].submit(1000000, &d_now); // 1 sec 409 409 410 410 s_throttle.throttle(d_now.tv_sec, remoteIP+"|"+qname+"|"+qtype.getName(),20,5); … … 432 432 } 433 433 LOG<<prefix<<qname<<": Got "<<result.size()<<" answers from "<<*tns<<" ("<<remoteIP<<"), rcode="<<d_lwr.d_rcode<<", in "<<d_lwr.d_usec/1000<<"ms"<<endl; 434 nsSpeeds[toLower(*tns)].submit(d_lwr.d_usec, &d_now);434 s_nsSpeeds[toLower(*tns)].submit(d_lwr.d_usec, &d_now); 435 435 436 436 map<string,set<DNSResourceRecord> > tcache; -
trunk/pdns/pdns/syncres.hh
r469 r535 65 65 else if(i->second.ttd > e.ttd || (i->second.count) < e.count) 66 66 d_cont[t]=e; 67 67 } 68 69 unsigned int size() 70 { 71 return d_cont.size(); 68 72 } 69 73 private: … … 165 169 unsigned int d_timeouts; 166 170 static map<string,NegCacheEntry> s_negcache; 171 static map<string,DecayingEwma> s_nsSpeeds; 167 172 static Throttle<string> s_throttle; 168 173 private: