From 3194f0df52dfd0aecd0b5a9bfd502cfb189a3605 Mon Sep 17 00:00:00 2001 From: Mark Zealey Date: Fri, 13 Dec 2013 22:39:47 +0200 Subject: [PATCH] On testing with large numbers of unknown domains the send-root-referral argument query amounted to quite a high proportion of CPU time. This will cache it to reduce this overhead as is already done with a number of variables. --- pdns/packethandler.cc | 13 +++++++++++-- pdns/packethandler.hh | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index e43802403..22d6ff911 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -52,6 +52,12 @@ AtomicCounter PacketHandler::s_count; extern string s_programname; +enum root_referral { + NO_ROOT_REFERRAL, + LEAN_ROOT_REFERRAL, + FULL_ROOT_REFERRAL +}; + PacketHandler::PacketHandler():B(s_programname) { ++s_count; @@ -59,6 +65,9 @@ PacketHandler::PacketHandler():B(s_programname) d_doRecursion= ::arg().mustDo("recursor"); d_logDNSDetails= ::arg().mustDo("log-dns-details"); d_doIPv6AdditionalProcessing = ::arg().mustDo("do-ipv6-additional-processing"); + d_sendRootReferral = ::arg().mustDo("send-root-referral") + ? ( pdns_iequals(::arg()["send-root-referral"], "lean") ? LEAN_ROOT_REFERRAL : FULL_ROOT_REFERRAL ) + : NO_ROOT_REFERRAL; string fname= ::arg()["lua-prequery-script"]; if(fname.empty()) { @@ -102,7 +111,7 @@ void PacketHandler::addRootReferral(DNSPacket* r) r->addRecord(rr); } - if(pdns_iequals(::arg()["send-root-referral"], "lean")) + if( d_sendRootReferral == LEAN_ROOT_REFERRAL ) return; // add the additional stuff @@ -1242,7 +1251,7 @@ DNSPacket *PacketHandler::questionOrRecurse(DNSPacket *p, bool *shouldRecurse) if(!retargetcount) r->setA(false); // drop AA if we never had a SOA in the first place - if(::arg().mustDo("send-root-referral")) { + if( d_sendRootReferral != NO_ROOT_REFERRAL ) { DLOG(L<