]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/worker: smaller starting mempool per request (16k)
authorMarek Vavruša <marek.vavrusa@nic.cz>
Tue, 14 Jul 2015 11:26:42 +0000 (13:26 +0200)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Tue, 14 Jul 2015 13:11:03 +0000 (15:11 +0200)
an average request from cache requires ~12k, an average iterative request 16-64k
this reduces allocation cost when there are now pools on the freelist

daemon/engine.h
daemon/worker.c

index 13dc097b13455287bffe4f3883924edff6181ce2..d791fbc9e8b5b94e00713585786ed5c4c7bf4db6 100644 (file)
@@ -27,7 +27,7 @@
 #define MP_FREELIST_SIZE 32 /**< Maximum length of the worker mempool freelist */
 #endif
 #ifndef RECVMMSG_BATCH
-#define RECVMMSG_BATCH 8
+#define RECVMMSG_BATCH 5
 #endif
 
 /*
index 680849e1402a50505e8154591ef3d5e0a0919b01..d1619274fff9745e46a0a28ea7eb095912a4ebbe 100644 (file)
@@ -52,7 +52,7 @@ static inline struct ioreq *ioreq_take(struct worker_ctx *worker)
 
 static inline void ioreq_release(struct worker_ctx *worker, struct ioreq *req)
 {
-       if (!req || worker->ioreqs.len < MP_FREELIST_SIZE) {
+       if (!req || worker->ioreqs.len < 4 * MP_FREELIST_SIZE) {
                array_push(worker->ioreqs, req);
        } else {
                free(req);
@@ -108,7 +108,7 @@ static struct qr_task *qr_task_create(struct worker_ctx *worker, uv_handle_t *ha
                pool.ctx = array_tail(worker->pools);
                array_pop(worker->pools);
        } else { /* No mempool on the freelist, create new one */
-               pool.ctx = mp_new (20 * CPU_PAGE_SIZE);
+               pool.ctx = mp_new (4 * CPU_PAGE_SIZE);
        }
 
        /* Create worker task */
@@ -132,6 +132,9 @@ static struct qr_task *qr_task_create(struct worker_ctx *worker, uv_handle_t *ha
                answer_max = KNOT_WIRE_MAX_PKTSIZE;
        } else if (knot_pkt_has_edns(query)) { /* EDNS */
                answer_max = knot_edns_get_payload(query->opt_rr);
+               if (answer_max < KNOT_WIRE_MIN_PKTSIZE) {
+                       answer_max = KNOT_WIRE_MIN_PKTSIZE;
+               }
        }
        /* How much space do we need for intermediate packets? */
        size_t pktbuf_max = KNOT_EDNS_MAX_UDP_PAYLOAD;