From 2705e1333922590cca6f7e8f4a5528d03ea14d1c Mon Sep 17 00:00:00 2001 From: Alessio Podda Date: Mon, 5 May 2025 11:43:44 +0200 Subject: [PATCH] Tune min and max chunk size Before implementing adaptive chunk sizing, it was necessary to ensure that a chunk could hold up to 48 twigs, but the new logic will size-up new chunks to ensure that the current allocation can succeed. We exploit the new logic in two ways: - We make the minimum chunk size smaller than the old limit of 2^6, reducing memory consumption. - We make the maximum chunk size larger, as it has been observed that it improves resolver performance. (cherry picked from commit d7064c9b88555918778822881a156e6f8864ea98) --- lib/dns/qp.c | 7 +++++-- lib/dns/qp_p.h | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/dns/qp.c b/lib/dns/qp.c index 07080f5bd2..7156efc4fe 100644 --- a/lib/dns/qp.c +++ b/lib/dns/qp.c @@ -49,7 +49,7 @@ #include "qp_p.h" #ifndef DNS_QP_LOG_STATS -#define DNS_QP_LOG_STATS 1 +#define DNS_QP_LOG_STATS 0 #endif #ifndef DNS_QP_TRACE #define DNS_QP_TRACE 0 @@ -1304,7 +1304,10 @@ dns_qpmulti_commit(dns_qpmulti_t *multi, dns_qp_t **qptp) { */ void dns_qpmulti_rollback(dns_qpmulti_t *multi, dns_qp_t **qptp) { - unsigned int nfree = 0; + /* + * nfree is only used when logging stats, hence the attribute. + */ + unsigned int nfree ISC_ATTR_UNUSED = 0; REQUIRE(QPMULTI_VALID(multi)); REQUIRE(multi->writer.transaction_mode == QP_UPDATE); diff --git a/lib/dns/qp_p.h b/lib/dns/qp_p.h index d61c4a0007..666d6fb9ed 100644 --- a/lib/dns/qp_p.h +++ b/lib/dns/qp_p.h @@ -143,14 +143,14 @@ enum { * size to make the allocator work harder. */ #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -#define QP_CHUNK_LOG_MIN 6 +#define QP_CHUNK_LOG_MIN 7 #define QP_CHUNK_LOG_MAX 7 #else -#define QP_CHUNK_LOG_MIN 6 -#define QP_CHUNK_LOG_MAX 10 +#define QP_CHUNK_LOG_MIN 3 +#define QP_CHUNK_LOG_MAX 12 #endif -STATIC_ASSERT(6 <= QP_CHUNK_LOG_MIN && QP_CHUNK_LOG_MIN <= QP_CHUNK_LOG_MAX, +STATIC_ASSERT(2 <= QP_CHUNK_LOG_MIN && QP_CHUNK_LOG_MIN <= QP_CHUNK_LOG_MAX, "qp-trie min chunk size is unreasonable"); STATIC_ASSERT(6 <= QP_CHUNK_LOG_MAX && QP_CHUNK_LOG_MAX <= 20, "qp-trie max chunk size is unreasonable");