Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rec: Count a lookup into an internal auth zone as a cache miss #6313

Merged
merged 3 commits into from Mar 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion pdns/pdns_recursor.cc
Expand Up @@ -1288,7 +1288,12 @@ static void startDoResolve(void *p)

}

sr.d_outqueries ? t_RC->cacheMisses++ : t_RC->cacheHits++;
if (sr.d_outqueries || sr.d_authzonequeries) {
t_RC->cacheMisses++;
}
else {
t_RC->cacheHits++;
}

if(spent < 0.001)
g_stats.answers0_1++;
Expand Down
26 changes: 11 additions & 15 deletions pdns/rec_channel_rec.cc
Expand Up @@ -39,33 +39,28 @@
#include "namespaces.hh"
pthread_mutex_t g_carbon_config_lock=PTHREAD_MUTEX_INITIALIZER;

map<string, const uint32_t*> d_get32bitpointers;
map<string, const uint64_t*> d_get64bitpointers;
map<string, const std::atomic<uint64_t>*> d_getatomics;
map<string, function< uint64_t() > > d_get64bitmembers;
pthread_mutex_t d_dynmetricslock = PTHREAD_MUTEX_INITIALIZER;
map<string, std::atomic<unsigned long>* > d_dynmetrics;
void addGetStat(const string& name, const uint32_t* place)
static map<string, const uint32_t*> d_get32bitpointers;
static map<string, const uint64_t*> d_get64bitpointers;
static map<string, const std::atomic<uint64_t>*> d_getatomics;
static map<string, function< uint64_t() > > d_get64bitmembers;
static pthread_mutex_t d_dynmetricslock = PTHREAD_MUTEX_INITIALIZER;
static map<string, std::atomic<unsigned long>* > d_dynmetrics;

static void addGetStat(const string& name, const uint32_t* place)
{
d_get32bitpointers[name]=place;
}
void addGetStat(const string& name, const uint64_t* place)
{
d_get64bitpointers[name]=place;
}

void addGetStat(const string& name, const std::atomic<uint64_t>* place)
static void addGetStat(const string& name, const std::atomic<uint64_t>* place)
{
d_getatomics[name]=place;
}


void addGetStat(const string& name, function<uint64_t ()> f )
static void addGetStat(const string& name, function<uint64_t ()> f )
{
d_get64bitmembers[name]=f;
}


std::atomic<unsigned long>* getDynMetric(const std::string& str)
{
Lock l(&d_dynmetricslock);
Expand Down Expand Up @@ -930,6 +925,7 @@ void registerAllStats()
addGetStat("outgoing-timeouts", &SyncRes::s_outgoingtimeouts);
addGetStat("outgoing4-timeouts", &SyncRes::s_outgoing4timeouts);
addGetStat("outgoing6-timeouts", &SyncRes::s_outgoing6timeouts);
addGetStat("auth-zone-queries", &SyncRes::s_authzonequeries);
addGetStat("tcp-outqueries", &SyncRes::s_tcpoutqueries);
addGetStat("all-outqueries", &SyncRes::s_outqueries);
addGetStat("ipv6-outqueries", &g_stats.ipv6queries);
Expand Down
4 changes: 4 additions & 0 deletions pdns/recursordist/docs/metrics.rst
Expand Up @@ -144,6 +144,10 @@ auth6-answers100-1000
^^^^^^^^^^^^^^^^^^^^^
counts the number of queries answered by auth6s within 1 second (4.0)

auth-zone-queries
^^^^^^^^^^^^^^^^^
counts the number of queries to locally hosted authoritative zones (:ref:`setting-auth-zones`) since starting

cache-bytes
^^^^^^^^^^^
size of the cache in bytes
Expand Down
8 changes: 6 additions & 2 deletions pdns/syncres.cc
Expand Up @@ -57,6 +57,7 @@ unsigned int SyncRes::s_packetcachettl;
unsigned int SyncRes::s_packetcacheservfailttl;
unsigned int SyncRes::s_serverdownmaxfails;
unsigned int SyncRes::s_serverdownthrottletime;
std::atomic<uint64_t> SyncRes::s_authzonequeries;
std::atomic<uint64_t> SyncRes::s_queries;
std::atomic<uint64_t> SyncRes::s_outgoingtimeouts;
std::atomic<uint64_t> SyncRes::s_outgoing4timeouts;
Expand Down Expand Up @@ -107,7 +108,7 @@ static void accountAuthLatency(int usec, int family)
}


SyncRes::SyncRes(const struct timeval& now) : d_outqueries(0), d_tcpoutqueries(0), d_throttledqueries(0), d_timeouts(0), d_unreachables(0),
SyncRes::SyncRes(const struct timeval& now) : d_authzonequeries(0), d_outqueries(0), d_tcpoutqueries(0), d_throttledqueries(0), d_timeouts(0), d_unreachables(0),
d_totUsec(0), d_now(now),
d_cacheonly(false), d_doDNSSEC(false), d_doEDNS0(false), d_lm(s_lm)

Expand Down Expand Up @@ -320,8 +321,11 @@ int SyncRes::AuthDomain::getRecords(const DNSName& qname, uint16_t qtype, std::v
return result;
}

bool SyncRes::doOOBResolve(const AuthDomain& domain, const DNSName &qname, const QType &qtype, vector<DNSRecord>&ret, int& res) const
bool SyncRes::doOOBResolve(const AuthDomain& domain, const DNSName &qname, const QType &qtype, vector<DNSRecord>&ret, int& res)
{
d_authzonequeries++;
s_authzonequeries++;

res = domain.getRecords(qname, qtype.getCode(), ret);
return true;
}
Expand Down
4 changes: 3 additions & 1 deletion pdns/syncres.hh
Expand Up @@ -669,6 +669,7 @@ public:
static std::atomic<uint64_t> s_outgoing6timeouts;
static std::atomic<uint64_t> s_throttledqueries;
static std::atomic<uint64_t> s_dontqueries;
static std::atomic<uint64_t> s_authzonequeries;
static std::atomic<uint64_t> s_outqueries;
static std::atomic<uint64_t> s_tcpoutqueries;
static std::atomic<uint64_t> s_nodelegated;
Expand Down Expand Up @@ -697,6 +698,7 @@ public:

std::unordered_map<std::string,bool> d_discardedPolicies;
DNSFilterEngine::Policy d_appliedPolicy;
unsigned int d_authzonequeries;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable should be initialized here

unsigned int d_outqueries;
unsigned int d_tcpoutqueries;
unsigned int d_throttledqueries;
Expand Down Expand Up @@ -736,7 +738,7 @@ private:
bool processAnswer(unsigned int depth, LWResult& lwr, const DNSName& qname, const QType& qtype, DNSName& auth, bool wasForwarded, const boost::optional<Netmask> ednsmask, bool sendRDQuery, NsSet &nameservers, std::vector<DNSRecord>& ret, const DNSFilterEngine& dfe, bool* gotNewServers, int* rcode, vState& state);

int doResolve(const DNSName &qname, const QType &qtype, vector<DNSRecord>&ret, unsigned int depth, set<GetBestNSAnswer>& beenthere, vState& state);
bool doOOBResolve(const AuthDomain& domain, const DNSName &qname, const QType &qtype, vector<DNSRecord>&ret, int& res) const;
bool doOOBResolve(const AuthDomain& domain, const DNSName &qname, const QType &qtype, vector<DNSRecord>&ret, int& res);
bool doOOBResolve(const DNSName &qname, const QType &qtype, vector<DNSRecord>&ret, unsigned int depth, int &res);
domainmap_t::const_iterator getBestAuthZone(DNSName* qname) const;
bool doCNAMECacheCheck(const DNSName &qname, const QType &qtype, vector<DNSRecord>&ret, unsigned int depth, int &res, vState& state, bool wasAuthZone);
Expand Down