From: Otto Date: Fri, 26 Feb 2021 09:44:01 +0000 (+0100) Subject: Use 1-2-5 histogram buckets and count packet cache hits. X-Git-Tag: dnsdist-1.7.0-alpha1~116^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e4e2d9d4eabef68a81d43cd0844156fa6536843;p=thirdparty%2Fpdns.git Use 1-2-5 histogram buckets and count packet cache hits. --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index b827632c3c..af1294f806 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -2679,6 +2679,10 @@ static void handleRunningTCPQuestion(int fd, FDMultiplexer::funcparam_t& var) /* we can't move this if we want to be able to access the values in all queries sent over this connection */ dc->d_proxyProtocolValues = conn->proxyProtocolValues; + + struct timeval start; + Utility::gettimeofday(&start, nullptr); + DNSName qname; uint16_t qtype=0; uint16_t qclass=0; @@ -2814,9 +2818,10 @@ static void handleRunningTCPQuestion(int fd, FDMultiplexer::funcparam_t& var) bool cacheHit = checkForCacheHit(qnameParsed, dc->d_tag, conn->data, qname, qtype, qclass, g_now, response, dc->d_qhash, pbData, true, dc->d_source); if (cacheHit) { + struct timeval now; + Utility::gettimeofday(&now, nullptr); if (t_protobufServers && dc->d_logResponse && !(luaconfsLocal->protobufExportConfig.taggedOnly && pbData && !pbData->d_tagged)) { - struct timeval tv{0, 0}; - protobufLogResponse(dh, luaconfsLocal, pbData, tv, true, dc->d_source, dc->d_destination, dc->d_ednssubnet, dc->d_uuid, dc->d_requestorId, dc->d_deviceId, dc->d_deviceName); + protobufLogResponse(dh, luaconfsLocal, pbData, now, true, dc->d_source, dc->d_destination, dc->d_ednssubnet, dc->d_uuid, dc->d_requestorId, dc->d_deviceId, dc->d_deviceName); } if (!g_quiet) { @@ -2825,6 +2830,9 @@ static void handleRunningTCPQuestion(int fd, FDMultiplexer::funcparam_t& var) bool hadError = sendResponseOverTCP(dc, response); finishTCPReply(dc, hadError, false); + Utility::gettimeofday(&now, nullptr); + uint64_t spentUsec = uSec(now - start); + g_stats.cumulativeAnswers(spentUsec); } else { // No cache hit, setup for startDoResolve() in an mthread ++conn->d_requestsInFlight; @@ -2913,7 +2921,7 @@ static void handleNewTCPQuestion(int fd, FDMultiplexer::funcparam_t& ) } struct timeval ttd; - Utility::gettimeofday(&ttd, 0); + Utility::gettimeofday(&ttd, nullptr); ttd.tv_sec += g_tcpTimeout; t_fdm->addReadFD(tc->getFD(), handleRunningTCPQuestion, tc, &ttd); @@ -2922,7 +2930,7 @@ static void handleNewTCPQuestion(int fd, FDMultiplexer::funcparam_t& ) static string* doProcessUDPQuestion(const std::string& question, const ComboAddress& fromaddr, const ComboAddress& destaddr, ComboAddress source, ComboAddress destination, struct timeval tv, int fd, std::vector& proxyProtocolValues) { - gettimeofday(&g_now, 0); + gettimeofday(&g_now, nullptr); if (tv.tv_sec) { struct timeval diff = g_now - tv; double delta=(diff.tv_sec*1000 + diff.tv_usec/1000.0); @@ -3069,6 +3077,10 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr << (source != fromaddr ? " (via " + fromaddr.toStringWithPort() + ")" : "") << " failed with: " << strerror(sendErr) << endl; } + struct timeval now; + Utility::gettimeofday(&now, nullptr); + uint64_t spentUsec = uSec(now - tv); + g_stats.cumulativeAnswers(spentUsec); return 0; } } @@ -5526,7 +5538,7 @@ try last_stat = g_now.tv_sec; } - Utility::gettimeofday(&g_now, 0); + Utility::gettimeofday(&g_now, nullptr); if((g_now.tv_sec - last_carbon) >= carbonInterval) { MT->makeThread(doCarbonDump, 0); diff --git a/pdns/syncres.hh b/pdns/syncres.hh index bf3f852c30..df61d54955 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -1058,9 +1058,9 @@ struct RecursorStats auth4Answers("auth4answers", { 1000, 10000, 100000, 1000000 }), auth6Answers("auth6answers", { 1000, 10000, 100000, 1000000 }), ourtime("ourtime", { 1000, 2000, 4000, 8000, 16000, 32000 }), - cumulativeAnswers("cumulAnswers-us", { 100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200, 102400, 204800, 409600, 819200, 1638400, 3276800, 6553600 }), - cumulativeAuth4Answers("cumulAuth4Answers-us", { 100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200, 102400, 204800, 409600, 819200, 1638400, 3276800, 6553600 }), - cumulativeAuth6Answers("cumulAuth6Answers-us", { 100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200, 102400, 204800, 409600, 819200, 1638400, 3276800, 6553600 }) + cumulativeAnswers("cumulAnswers-us", 10, 19), + cumulativeAuth4Answers("cumulAuth4Answers-us", 1000, 13), + cumulativeAuth6Answers("cumulAuth6Answers-us", 1000, 13) { } };