From: Daniel Salzman Date: Mon, 19 Jul 2021 11:23:49 +0000 (+0200) Subject: server: reduce the worker_pool_status() overhead in the case of many zones X-Git-Tag: v3.1.0~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=397515ed91d0bdb6984d6b66c9369153e54ce359;p=thirdparty%2Fknot-dns.git server: reduce the worker_pool_status() overhead in the case of many zones --- diff --git a/src/knot/server/server.c b/src/knot/server/server.c index 61a5157f7d..d3d031fa45 100644 --- a/src/knot/server/server.c +++ b/src/knot/server/server.c @@ -745,10 +745,18 @@ static void server_free_handler(iohandler_t *h) static void worker_wait_cb(worker_pool_t *pool) { - int running, queued; systemd_zone_load_timeout_notify(); - worker_pool_status(pool, true, &running, &queued); - systemd_tasks_status_notify(running + queued); + + static uint64_t last_ns = 0; + struct timespec now = time_now(); + uint64_t now_ns = 1000000000 * now.tv_sec + now.tv_nsec; + /* Too frequent worker_pool_status() call with many zones is expensive. */ + if (now_ns - last_ns > 1000000000) { + int running, queued; + worker_pool_status(pool, true, &running, &queued); + systemd_tasks_status_notify(running + queued); + last_ns = now_ns; + } } int server_start(server_t *server, bool async)