]> granicus.if.org Git - pdns/commitdiff
remove old tsc based timer infrastructure, beef up #ifdef to prevent using the high...
authorbert hubert <bert.hubert@netherlabs.nl>
Thu, 15 Jan 2015 12:43:28 +0000 (13:43 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Thu, 15 Jan 2015 12:43:28 +0000 (13:43 +0100)
pdns/Makefile.am
pdns/htimer.cc [deleted file]
pdns/htimer.hh [deleted file]
pdns/misc.hh
pdns/pdns_recursor.cc

index db9db8d69bc1a62e4bd047c89f4a12c470fa9866..9dfe05428418c045df36ed0208795cde411b825b 100644 (file)
@@ -927,7 +927,6 @@ pdns_recursor_SOURCES = \
        dnsrecords.cc dnsrecords.hh \
        dnswriter.cc dnswriter.hh \
        epollmplexer.cc \
-       htimer.cc htimer.hh \
        iputils.cc \
        json.cc json.hh \
        logger.cc \
diff --git a/pdns/htimer.cc b/pdns/htimer.cc
deleted file mode 100644 (file)
index 1f4533d..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-#include <stdexcept>
-#include "htimer.hh"
-#include <iostream>
-
-HTimer::timers_t HTimer::s_timers;
-
-#include "namespaces.hh"
-#include "namespaces.hh"
-
-
-/* idea: nested timers, where the hierarchy of nesting is constructed at runtime. Each timer can have multiple
-   positions in the hierarchy, and might conceivable nest within itself.
-
-   Desired result:
-
-   Processing incoming questions
-      Rest
-      Parsing question
-        Rest
-        MOADNSParser
-      Searching cache
-      Processing Server Answers
-        Rest
-        MOADNSParser
-      Waiting for packets
-
-   Parsing question
-     Rest
-     MOADDNSParser
-
-   Processing Server Answers
-     Rest
-     MOADNSParser
-
-   Waiting for packets
-*/
-
-#define RDTSC(qp) \
-do { \
-  unsigned long lowPart, highPart;                                        \
-  __asm__ __volatile__("rdtsc" : "=a" (lowPart), "=d" (highPart)); \
-    qp = (((unsigned long long) highPart) << 32) | lowPart; \
-} while (0)
-
-HTimer::HTimer(const std::string& name) : d_accumulated(0), d_started(0)
-{
-  s_timers[name]=this;
-}
-
-HTimer::~HTimer()
-{
-  for(timers_t::iterator iter = s_timers.begin(); iter != s_timers.end() ; ++iter) {
-    if(iter->second == this) {
-      s_timers.erase(iter);
-      break;
-    }
-  }  
-}
-
-void HTimer::start()
-{
-  if(d_started)
-    throw runtime_error("HTimer restarted!");
-  RDTSC(d_started);
-}
-
-void HTimer::stop()
-{
-  if(!d_started)
-    throw runtime_error("HTimer stopped that wasn't started!");
-  uint64_t stopped;
-  RDTSC(stopped);
-
-  d_accumulated += stopped - d_started;
-  d_started=0;
-}
-
-uint64_t HTimer::getAccumulated() const
-{
-  uint64_t accumulated = d_accumulated;
-  if(d_started) {
-    uint64_t midterm;
-    RDTSC(midterm);
-
-    accumulated += midterm - d_started;
-  }
-  return accumulated;
-}
-
-uint64_t HTimer::getAccumulatedReset() 
-{
-  uint64_t accumulated = d_accumulated;
-  if(d_started) {
-    uint64_t midterm;
-    RDTSC(midterm);
-
-    accumulated += midterm - d_started;
-    d_started=midterm;
-  }
-  d_accumulated=0;
-  return accumulated;
-}
-
-
-HTimerSentinel HTimer::getSentinel()
-{
-  return HTimerSentinel(this);
-}
-
-void HTimer::listAll()
-{
-  for(timers_t::iterator iter = s_timers.begin(); iter != s_timers.end() ; ++iter) {
-    cerr << iter->first <<": " << iter->second->getAccumulatedReset()/3000.0 <<"usec\n";
-  }
-}
-
-#if 0
-int main()
-{
-  char *q = new char;
-  delete q;
-
-  HTimer htmain("main");
-  htmain.start();
-
-  HTimer htloop("loop");
-  {
-    HTimerSentinel hts=htloop.getSentinel();
-    for(int i=0; i < 1000; ++i)
-    {
-      shared_ptr<char> p(shared_ptr<char>(new char));
-    }
-  }
-
-  htloop.listAll();
-
-  cerr<<"accumulated: "<< htmain.getAccumulated() <<endl;
-  cerr<<"accumulated: "<< htloop.getAccumulated() <<endl;
-}
-#endif
diff --git a/pdns/htimer.hh b/pdns/htimer.hh
deleted file mode 100644 (file)
index e45395e..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-#ifndef PDNS_HTIMER_HH
-#define PDNS_HTIMER_HH
-#include <stdint.h>
-#include <boost/shared_ptr.hpp>
-#include <boost/utility.hpp>
-#include <map>
-
-class HTimerSentinel;
-// typedef boost::shared_ptr<HTimerSentinelImp> HTimerSentinel;
-
-class HTimer : public boost::noncopyable
-{
-public:
-  HTimer(){};
-  explicit HTimer(const std::string& name);
-  ~HTimer();
-  void start();
-  void stop();
-  uint64_t getAccumulated() const;
-  uint64_t getAccumulatedReset();
-
-  HTimerSentinel getSentinel();
-  static void listAll();
-
-private:
-  typedef std::map<std::string, HTimer*> timers_t;
-  static timers_t s_timers;
-  uint64_t d_accumulated;
-  uint64_t d_started;
-};
-
-class HTimerSentinel
-{
-public:
-  explicit HTimerSentinel(class HTimer* parent) : d_parent(parent)
-  {
-    d_rc=1;
-    d_parent->start();
-  }
-
-  HTimerSentinel(const HTimerSentinel& orig)
-  {
-    d_parent = orig.d_parent;
-    orig.d_rc++;
-  }
-  
-  ~HTimerSentinel()
-  {
-    if(!--d_rc)
-      d_parent->stop();
-  }
-
-private:  
-  HTimerSentinel& operator=(const HTimerSentinel& rhs);
-  HTimer* d_parent;
-
-  mutable unsigned int d_rc;
-};
-
-class HTimerSentinelImp : public boost::noncopyable
-{
-public:
-  explicit HTimerSentinelImp(class HTimer* parent) : d_parent(parent)
-  {
-    d_parent->start();
-  }
-
-  ~HTimerSentinelImp()
-  {
-    d_parent->stop();
-  }
-
-private:
-  HTimer* d_parent;
-};
-
-#endif
index e7c72e0de7d27ca7306e130a567e4dd98b824fdd..515e35fe5fc056ed8fbce940ae22499796e2c2a0 100644 (file)
 #include <boost/multi_index/key_extractors.hpp>
 #include <boost/multi_index/sequenced_index.hpp>
 using namespace ::boost::multi_index;
-#if 0
-#include <iostream>
-using std::cout;
-using std::endl;
-
-struct TSCTimer
-{
-  TSCTimer()
-  {
-    RDTSC(d_tsc1);
-  }
-  ~TSCTimer()
-  {
-    uint64_t tsc2;
-    RDTSC(tsc2);
-    cout<<"Timer: "<< (tsc2 - d_tsc1)/3000.0 << endl;
-  }
-  uint64_t d_tsc1;
-};
-#endif
 
 #include "utility.hh"
 #include "dns.hh"
@@ -181,7 +161,7 @@ int makeGidNumeric(const string &group);
 int makeUidNumeric(const string &user);
 void cleanSlashes(string &str);
 
-#ifdef _POSIX_THREAD_CPUTIME
+#if defined(_POSIX_THREAD_CPUTIME) && defined(CLOCK_THREAD_CPUTIME_ID)
 /** CPUTime measurements */
 class CPUTime
 {
index 5cda0f0f4f47dd7476669a4d8714eec9385df035..1c8480a071f8b609d39fd45cdf2b1db833b47e18 100644 (file)
@@ -755,6 +755,7 @@ void startDoResolve(void *p)
     newLat = min(newLat,(uint64_t)(g_networkTimeoutMsec*1000)); // outliers of several minutes exist..
     g_stats.avgLatencyUsec=(1-1.0/g_latencyStatSize)*g_stats.avgLatencyUsec + (float)newLat/g_latencyStatSize;
     // no worries, we do this for packet cache hits elsewhere
+    //    cout<<dc->d_mdp.d_qname<<"\t"<<MT->getUsec()<<"\t"<<sr.d_outqueries<<endl;
     delete dc;
     dc=0;
   }