]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
A separate setting for packet cache shards.
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 17 Mar 2023 13:09:00 +0000 (14:09 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 3 Apr 2023 11:31:47 +0000 (13:31 +0200)
pdns/recursordist/RECURSOR-MIB.txt
pdns/recursordist/docs/settings.rst
pdns/recursordist/rec-main.cc
pdns/recursordist/rec-tcounters.hh

index 5d04fa74f61144673a3a54ec3fd60a164a3065a0..40b26617a90a3cf8571dede91a4a8db619a65b81 100644 (file)
@@ -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"
index fce382f5f042da0e7483d6bd9d99c9b5d62bb0f7..ec4c60e65faa7100d05c067a1b48b868df705be8 100644 (file)
@@ -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``
index b514e7b2e054b4248c96126c81e9fb9aa2c5084d..52dfa60d22175ae3979f7c2294f577b5385cf5e5 100644 (file)
@@ -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<NegCache>(::arg().asNum("record-cache-shards") / 8);
     if (!::arg().mustDo("disable-packetcache")) {
       g_maxPacketCacheEntries = ::arg().asNum("max-packetcache-entries");
-      g_packetCache = std::make_unique<RecursorPacketCache>(g_maxPacketCacheEntries, ::arg().asNum("record-cache-shards")); // XXX
+      g_packetCache = std::make_unique<RecursorPacketCache>(g_maxPacketCacheEntries, ::arg().asNum("packetcache-shards"));
     }
 
     ret = serviceMain(argc, argv, startupLog);
index db5b3111924081fececf298ce8defa2d3da7b6d3..7d59bde46cfc91d4429d444c13bf65a45be438d6 100644 (file)
@@ -95,8 +95,6 @@ enum class Counter : uint8_t
   maintenanceUsec,
   maintenanceCalls,
 
-  pcHits,
-  pcMisses,
   numberOfCounters
 };