2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 05:57:52 +00:00

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)
This commit is contained in:
Alessio Podda 2025-05-05 11:43:44 +02:00
parent d21f63884a
commit 2705e13339
2 changed files with 9 additions and 6 deletions

View File

@ -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);

View File

@ -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");