From: Ondřej Surý Date: Mon, 10 Aug 2020 07:02:30 +0000 (+0200) Subject: Reduce the default RBT hash table size to 16 entries (4 bits) X-Git-Tag: v9.17.4^0 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9a2a819817405ad42fd99b64ff8eeedb28ce4604;p=thirdparty%2Fbind9.git Reduce the default RBT hash table size to 16 entries (4 bits) The hash table rework MRs (!3865, !3871) increased the default RBT hash table size from 64 to 65,536 entries (for 64-bit architectures, that is 512 bytes before vs. 524,288 bytes after). This works fine for RBTs used for cache databases, but since three separate RBT databases are created for every zone loaded (RRs, NSEC, NSEC3), memory usage would skyrocket when BIND 9 is used as an authoritative DNS server with many zones. The default RBT hash table size before the rework was 64 entries, this commit reduces it to 16 entries because our educated guess is that most zones are just couple of entries (SOA, NS, A, AAAA, MX) and rehashing small hash tables is actually cheap. The rework we did in the previous MRs tries to avoid growing the hash tables for big-to-huge caches where growing the hash table comes at a price because the whole cache needs to be locked. (cherry picked from commit 1e043a011b9fe3f62f9f5c7a9b74b44adc03ca44) --- diff --git a/lib/dns/rbt.c b/lib/dns/rbt.c index eb7029355e1..aaa1acf6c7c 100644 --- a/lib/dns/rbt.c +++ b/lib/dns/rbt.c @@ -59,7 +59,7 @@ #define CHAIN_MAGIC ISC_MAGIC('0', '-', '0', '-') #define VALID_CHAIN(chain) ISC_MAGIC_VALID(chain, CHAIN_MAGIC) -#define RBT_HASH_MIN_BITS 16 +#define RBT_HASH_MIN_BITS 4 #define RBT_HASH_MAX_BITS 32 #define RBT_HASH_OVERCOMMIT 3 #define RBT_HASH_BUCKETSIZE 4096 /* FIXME: What would be a good value here? */