From eafee0286549348be2d6551c30496a299fef7b84 Mon Sep 17 00:00:00 2001 From: Gregory Burd Date: Fri, 26 Apr 2013 10:15:15 -0400 Subject: [PATCH] Only start 2 * num_queues worker threads initially. num_queues is generally equal to the number of cores reported by Erlang (info.scheduler_threads) which is either determined automatically by the Erlang BEAM runtime or via the +S flag. The minimum num_queues is 2, so the minimum number of workers is 4. The maximum number of workers is ASYNC_NIF_MAX_WORKER_QUEUE_SIZE (currently set to 128), but that would only happen if there were 64 cores (or you set +S 64:64 at startup). --- c_src/async_nif.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/c_src/async_nif.h b/c_src/async_nif.h index 4938ed0..fd8b19d 100644 --- a/c_src/async_nif.h +++ b/c_src/async_nif.h @@ -36,7 +36,7 @@ extern "C" { #define __UNUSED(v) ((void)(v)) #endif -#define ASYNC_NIF_MAX_WORKERS 1024 +#define ASYNC_NIF_MAX_WORKERS 128 #define ASYNC_NIF_WORKER_QUEUE_SIZE 500 #define ASYNC_NIF_MAX_QUEUED_REQS 1000 * ASYNC_NIF_MAX_WORKERS @@ -431,7 +431,7 @@ async_nif_load() sizeof(struct async_nif_work_queue) * num_queues); async_nif->num_queues = num_queues; - async_nif->num_workers = ASYNC_NIF_MAX_WORKERS; // TODO: start with 2 per queue, then grow if needed + async_nif->num_workers = 2 * num_queues; async_nif->next_q = 0; async_nif->shutdown = 0; async_nif->recycled_reqs = fifo_q_new(reqs, ASYNC_NIF_MAX_QUEUED_REQS);