From 503813cd9c080d2a089484af7cc73d9e9ef42f82 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Fri, 17 Mar 2023 14:09:00 +0100 Subject: [PATCH] A separate setting for packet cache shards. --- pdns/recursordist/RECURSOR-MIB.txt | 6 ++++-- pdns/recursordist/docs/settings.rst | 13 +++++++++++++ pdns/recursordist/rec-main.cc | 11 +++++++---- pdns/recursordist/rec-tcounters.hh | 2 -- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/pdns/recursordist/RECURSOR-MIB.txt b/pdns/recursordist/RECURSOR-MIB.txt index 5d04fa74f6..40b26617a9 100644 --- a/pdns/recursordist/RECURSOR-MIB.txt +++ b/pdns/recursordist/RECURSOR-MIB.txt @@ -55,7 +55,7 @@ rec MODULE-IDENTITY DESCRIPTION "Added metrics for answers from auths by rcode" REVISION "202302240000Z" - DESCRIPTION "Added metrics for sharded packet cache contrntion" + DESCRIPTION "Added metrics for sharded packet cache contention" ::= { powerdns 2 } @@ -1423,7 +1423,9 @@ recGroup OBJECT-GROUP authrcode12Count, authrcode13Count, authrcode14Count, - authrcode15Count + authrcode15Count, + packetCacheContended, + packetCacheAcquired } STATUS current DESCRIPTION "Objects conformance group for PowerDNS Recursor" diff --git a/pdns/recursordist/docs/settings.rst b/pdns/recursordist/docs/settings.rst index fce382f5f0..ec4c60e65f 100644 --- a/pdns/recursordist/docs/settings.rst +++ b/pdns/recursordist/docs/settings.rst @@ -1618,6 +1618,19 @@ Before version 4.6.0 only ``ServFail`` answers were considered as such. Starting This setting's maximum is capped to `packetcache-ttl`_. i.e. setting ``packetcache-ttl=15`` and keeping ``packetcache-servfail-ttl`` at the default will lower ``packetcache-servfail-ttl`` to ``15``. + +.. _setting-packetcache-shards: + +``packetcache-shards`` +------------------------ +.. versionadded:: 4.9.0 + +- Integer +- Default: 1024 + +Sets the number of shards in the packet cache. If you have high contention as reported by ``packetcache-contented/packetcache-acquired``, +you can try to enlarge this value or run with fewer threads. + .. _setting-pdns-distributes-queries: ``pdns-distributes-queries`` diff --git a/pdns/recursordist/rec-main.cc b/pdns/recursordist/rec-main.cc index b514e7b2e0..52dfa60d22 100644 --- a/pdns/recursordist/rec-main.cc +++ b/pdns/recursordist/rec-main.cc @@ -1038,9 +1038,9 @@ static void doStats(void) "record-cache-contended", Logging::Loggable(rc_stats.first), "record-cache-acquired", Logging::Loggable(rc_stats.second), "record-cache-contended-perc", Logging::Loggable(rrc), - "packet-cache-contended", Logging::Loggable(pc_stats.first), - "packet-cache-acquired", Logging::Loggable(pc_stats.second), - "packet-cache-contended-perc", Logging::Loggable(rpc)); + "packetcache-contended", Logging::Loggable(pc_stats.first), + "packetcache-acquired", Logging::Loggable(pc_stats.second), + "packetcache-contended-perc", Logging::Loggable(rpc)); log->info(Logr::Info, m, "throttle-entries", Logging::Loggable(SyncRes::getThrottledServersSize()), "nsspeed-entries", Logging::Loggable(SyncRes::getNSSpeedsSize()), @@ -2808,7 +2808,10 @@ int main(int argc, char** argv) ::arg().setSwitch("nothing-below-nxdomain", "When an NXDOMAIN exists in cache for a name with fewer labels than the qname, send NXDOMAIN without doing a lookup (see RFC 8020)") = "dnssec"; ::arg().set("max-generate-steps", "Maximum number of $GENERATE steps when loading a zone from a file") = "0"; ::arg().set("max-include-depth", "Maximum nested $INCLUDE depth when loading a zone from a file") = "20"; + ::arg().set("record-cache-shards", "Number of shards in the record cache") = "1024"; + ::arg().set("packetcache-shards", "Number of shards in the packet cache") = "1024"; + ::arg().set("refresh-on-ttl-perc", "If a record is requested from the cache and only this % of original TTL remains, refetch") = "0"; ::arg().set("record-cache-locked-ttl-perc", "Replace records in record cache only after this % of original TTL has passed") = "0"; @@ -3035,7 +3038,7 @@ int main(int argc, char** argv) g_negCache = std::make_unique(::arg().asNum("record-cache-shards") / 8); if (!::arg().mustDo("disable-packetcache")) { g_maxPacketCacheEntries = ::arg().asNum("max-packetcache-entries"); - g_packetCache = std::make_unique(g_maxPacketCacheEntries, ::arg().asNum("record-cache-shards")); // XXX + g_packetCache = std::make_unique(g_maxPacketCacheEntries, ::arg().asNum("packetcache-shards")); } ret = serviceMain(argc, argv, startupLog); diff --git a/pdns/recursordist/rec-tcounters.hh b/pdns/recursordist/rec-tcounters.hh index db5b311192..7d59bde46c 100644 --- a/pdns/recursordist/rec-tcounters.hh +++ b/pdns/recursordist/rec-tcounters.hh @@ -95,8 +95,6 @@ enum class Counter : uint8_t maintenanceUsec, maintenanceCalls, - pcHits, - pcMisses, numberOfCounters }; -- 2.47.2