]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Adjust the fillcount and freemax for dns_message mempools
authorOndřej Surý <ondrej@sury.org>
Sun, 23 May 2021 13:36:06 +0000 (15:36 +0200)
committerOndřej Surý <ondrej@sury.org>
Mon, 24 May 2021 18:44:58 +0000 (20:44 +0200)
According to the measurements (recorded on GL!5085), the fillcount of 2
for namepool and fillcount of 4 for rdspool can fit 99.99% of request
for tested scenarios.

This was discovered by perf recording the single second recursive test
using flamethrower where the initial malloc lit up like a flare.

lib/dns/message.c

index f4fa576db260ada7c94339df09c0ae2ba40008fc..8f3efab6ec7dd9915f56ffb04513655fdef5ad03 100644 (file)
@@ -104,12 +104,14 @@ hexdump(const char *msg, const char *msg2, void *base, size_t len) {
  * of various block allocations used within the server.
  * XXXMLG These should come from a config setting.
  */
-#define SCRATCHPAD_SIZE 512
-#define NAME_COUNT     64
-#define OFFSET_COUNT   4
-#define RDATA_COUNT    8
-#define RDATALIST_COUNT 8
-#define RDATASET_COUNT 64
+#define SCRATCHPAD_SIZE           1232
+#define NAME_FILLCOUNT    4
+#define NAME_FREEMAX      8 * NAME_FILLCOUNT
+#define OFFSET_COUNT      4
+#define RDATA_COUNT       8
+#define RDATALIST_COUNT           8
+#define RDATASET_FILLCOUNT 4
+#define RDATASET_FREEMAX   8 * RDATASET_FILLCOUNT
 
 /*%
  * Text representation of the different items, for message_totext
@@ -733,13 +735,13 @@ dns_message_create(isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp) {
        ISC_LIST_INIT(m->freerdatalist);
 
        isc_mempool_create(m->mctx, sizeof(dns_fixedname_t), &m->namepool);
-       isc_mempool_setfillcount(m->namepool, NAME_COUNT);
-       isc_mempool_setfreemax(m->namepool, NAME_COUNT);
+       isc_mempool_setfillcount(m->namepool, NAME_FILLCOUNT);
+       isc_mempool_setfreemax(m->namepool, 32 * NAME_FREEMAX);
        isc_mempool_setname(m->namepool, "msg:names");
 
        isc_mempool_create(m->mctx, sizeof(dns_rdataset_t), &m->rdspool);
-       isc_mempool_setfillcount(m->rdspool, RDATASET_COUNT);
-       isc_mempool_setfreemax(m->rdspool, RDATASET_COUNT);
+       isc_mempool_setfillcount(m->rdspool, RDATASET_FILLCOUNT);
+       isc_mempool_setfreemax(m->rdspool, 32 * RDATASET_FREEMAX);
        isc_mempool_setname(m->rdspool, "msg:rdataset");
 
        isc_buffer_allocate(mctx, &dynbuf, SCRATCHPAD_SIZE);