]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Merge pull request #7649 from rgacogne/per-threads-cpu-stats
authorRemi Gacogne <rgacogne@users.noreply.github.com>
Mon, 8 Apr 2019 07:22:09 +0000 (09:22 +0200)
committerGitHub <noreply@github.com>
Mon, 8 Apr 2019 07:22:09 +0000 (09:22 +0200)
rec: This provides CPU usage statistics per thread (worker & distributor).

1  2 
pdns/pdns_recursor.cc
pdns/syncres.hh

diff --combined pdns/pdns_recursor.cc
index 60c58a8f313b9a79cb481d3f570112f9ac32e236,1c9f5746fc9e19df6fa5a2e6f3b4fcc5b8988ca6..311d861f5416b53de9fc12c5b5057dda3ff0eb90
@@@ -1629,10 -1629,8 +1629,10 @@@ static void startDoResolve(void *p
          else {
            dc->d_tcpConnection->state=TCPConnection::BYTE0;
            Utility::gettimeofday(&g_now, 0); // needs to be updated
 -          t_fdm->addReadFD(dc->d_socket, handleRunningTCPQuestion, dc->d_tcpConnection);
 -          t_fdm->setReadTTD(dc->d_socket, g_now, g_tcpTimeout);
 +          struct timeval ttd = g_now;
 +          ttd.tv_sec += g_tcpTimeout;
 +
 +          t_fdm->addReadFD(dc->d_socket, handleRunningTCPQuestion, dc->d_tcpConnection, &ttd);
          }
        }
      }
@@@ -2052,11 -2050,11 +2052,11 @@@ static void handleNewTCPQuestion(int fd
      std::shared_ptr<TCPConnection> tc = std::make_shared<TCPConnection>(newsock, addr);
      tc->state=TCPConnection::BYTE0;
  
 -    t_fdm->addReadFD(tc->getFD(), handleRunningTCPQuestion, tc);
 +    struct timeval ttd;
 +    Utility::gettimeofday(&ttd, 0);
 +    ttd.tv_sec += g_tcpTimeout;
  
 -    struct timeval now;
 -    Utility::gettimeofday(&now, 0);
 -    t_fdm->setReadTTD(tc->getFD(), now, g_tcpTimeout);
 +    t_fdm->addReadFD(tc->getFD(), handleRunningTCPQuestion, tc, &ttd);
    }
  }
  
@@@ -3033,6 -3031,7 +3033,7 @@@ template string broadcastAccFunction(co
  template uint64_t broadcastAccFunction(const boost::function<uint64_t*()>& fun); // explicit instantiation
  template vector<ComboAddress> broadcastAccFunction(const boost::function<vector<ComboAddress> *()>& fun); // explicit instantiation
  template vector<pair<DNSName,uint16_t> > broadcastAccFunction(const boost::function<vector<pair<DNSName, uint16_t> > *()>& fun); // explicit instantiation
+ template ThreadTimes broadcastAccFunction(const boost::function<ThreadTimes*()>& fun);
  
  static void handleRCC(int fd, FDMultiplexer::funcparam_t& var)
  {
@@@ -3712,9 -3711,6 +3713,9 @@@ static int serviceMain(int argc, char*a
    SyncRes::s_ecsipv4limit = ::arg().asNum("ecs-ipv4-bits");
    SyncRes::s_ecsipv6limit = ::arg().asNum("ecs-ipv6-bits");
    SyncRes::clearECSStats();
 +  SyncRes::s_ecsipv4cachelimit = ::arg().asNum("ecs-ipv4-cache-bits");
 +  SyncRes::s_ecsipv6cachelimit = ::arg().asNum("ecs-ipv6-cache-bits");
 +  SyncRes::s_ecscachelimitttl = ::arg().asNum("ecs-cache-limit-ttl");
  
    if (!::arg().isEmpty("ecs-scope-zero-address")) {
      ComboAddress scopeZero(::arg()["ecs-scope-zero-address"]);
@@@ -4330,11 -4326,8 +4331,11 @@@ int main(int argc, char **argv
      ::arg().set("latency-statistic-size","Number of latency values to calculate the qa-latency average")="10000";
      ::arg().setSwitch( "disable-packetcache", "Disable packetcache" )= "no";
      ::arg().set("ecs-ipv4-bits", "Number of bits of IPv4 address to pass for EDNS Client Subnet")="24";
 +    ::arg().set("ecs-ipv4-cache-bits", "Maximum number of bits of IPv4 mask to cache ECS response")="24";
      ::arg().set("ecs-ipv6-bits", "Number of bits of IPv6 address to pass for EDNS Client Subnet")="56";
 +    ::arg().set("ecs-ipv6-cache-bits", "Maximum number of bits of IPv6 mask to cache ECS response")="56";
      ::arg().set("ecs-minimum-ttl-override", "Set under adverse conditions, a minimum TTL for records in ECS-specific answers")="0";
 +    ::arg().set("ecs-cache-limit-ttl", "Minimum TTL to cache ECS response")="0";
      ::arg().set("edns-subnet-whitelist", "List of netmasks and domains that we should enable EDNS subnet for")="";
      ::arg().set("ecs-add-for", "List of client netmasks for which EDNS Client Subnet will be added")="0.0.0.0/0, ::/0, " LOCAL_NETS_INVERSE;
      ::arg().set("ecs-scope-zero-address", "Address to send to whitelisted authoritative servers for incoming queries with ECS prefix-length source of 0")="";
diff --combined pdns/syncres.hh
index a34fc4b9c45d9f86348089b560798018750c53fc,e2562a1c2f8e1b36006b6b44994db658538801c9..a28ca22c57a34c0a35d5cc362cc07c11ed217551
@@@ -716,11 -716,8 +716,11 @@@ public
    static unsigned int s_packetcacheservfailttl;
    static unsigned int s_serverdownmaxfails;
    static unsigned int s_serverdownthrottletime;
 +  static unsigned int s_ecscachelimitttl;
    static uint8_t s_ecsipv4limit;
    static uint8_t s_ecsipv6limit;
 +  static uint8_t s_ecsipv4cachelimit;
 +  static uint8_t s_ecsipv6cachelimit;
    static bool s_doIPv6;
    static bool s_noEDNSPing;
    static bool s_noEDNS;
@@@ -1040,3 -1037,14 +1040,14 @@@ void doCarbonDump(void*)
  void primeHints(void);
  
  extern __thread struct timeval g_now;
+ struct ThreadTimes
+ {
+   uint64_t msec;
+   vector<uint64_t> times;
+   ThreadTimes& operator+=(const ThreadTimes& rhs)
+   {
+     times.push_back(rhs.msec);
+     return *this;
+   }
+ };