From: bert hubert Date: Wed, 25 Nov 2015 13:55:01 +0000 (+0100) Subject: shave off 23 mallocs per cache miss X-Git-Tag: dnsdist-1.0.0-alpha1~202 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=756e82cf9c2c6918366004f0f6319a2e35af6e57;p=thirdparty%2Fpdns.git shave off 23 mallocs per cache miss --- diff --git a/pdns/dnsparser.cc b/pdns/dnsparser.cc index a884b347a0..5589ad8ff7 100644 --- a/pdns/dnsparser.cc +++ b/pdns/dnsparser.cc @@ -268,6 +268,7 @@ void MOADNSParser::init(const char *packet, unsigned int len) struct dnsrecordheader ah; vector record; validPacket=true; + d_answers.reserve((unsigned int)(d_header.ancount + d_header.nscount + d_header.arcount)); for(n=0;n < (unsigned int)(d_header.ancount + d_header.nscount + d_header.arcount); ++n) { DNSRecord dr; diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 9ad22f03bc..6e48f3e1c6 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -2090,6 +2090,15 @@ void parseEDNSSubnetWhitelist(const std::string& wlist) } } +SuffixMatchNode g_delegationOnly; +static void setupDelegationOnly() +{ + vector parts; + stringtok(parts, ::arg()["delegation-only"], ", \t"); + for(const auto& p : parts) { + g_delegationOnly.add(DNSName(p)); + } +} int serviceMain(int argc, char*argv[]) { @@ -2135,6 +2144,9 @@ int serviceMain(int argc, char*argv[]) L< nameservers, DNSName auth, bool flawedNSSe if(rec.d_name.isPartOf(auth)) { - if(lwr.d_aabit && lwr.d_rcode==RCode::NoError && rec.d_place==DNSResourceRecord::ANSWER && ::arg().contains("delegation-only",auth.toString() /* ugh */)) { + if(lwr.d_aabit && lwr.d_rcode==RCode::NoError && rec.d_place==DNSResourceRecord::ANSWER && g_delegationOnly.check(auth)) { LOG("NO! Is from delegation-only zone"< nameservers, DNSName auth, bool flawedNSSe dr.d_place=DNSResourceRecord::ANSWER; dr.d_ttl += d_now.tv_sec; - // we should note the PLACE and not store ECS subnet details for non-answer records tcache[{rec.d_name,rec.d_type,rec.d_place}].records.push_back(dr); } } diff --git a/pdns/syncres.hh b/pdns/syncres.hh index d3f39f425b..35c3a32d0c 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -632,7 +632,7 @@ string doTraceRegex(vector::const_iterator begin, vector::const_ void parseACLs(); extern RecursorStats g_stats; extern unsigned int g_numThreads; - +extern SuffixMatchNode g_delegationOnly; std::string reloadAuthAndForwards(); ComboAddress parseIPAndPort(const std::string& input, uint16_t port); ComboAddress getQueryLocalAddress(int family, uint16_t port);