From: Marek VavrusÌŒa Date: Tue, 14 Jul 2015 11:26:42 +0000 (+0200) Subject: daemon/worker: smaller starting mempool per request (16k) X-Git-Tag: v1.0.0-beta1~77^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b4f41ea22798bc36a1fbbc5a89fa518f57f6419c;p=thirdparty%2Fknot-resolver.git daemon/worker: smaller starting mempool per request (16k) 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 --- diff --git a/daemon/engine.h b/daemon/engine.h index 13dc097b1..d791fbc9e 100644 --- a/daemon/engine.h +++ b/daemon/engine.h @@ -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 /* diff --git a/daemon/worker.c b/daemon/worker.c index 680849e14..d1619274f 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -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;