From e60308808f58a3517170edf61245031cb899e59e Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Tue, 12 Jun 2018 00:40:37 -0700 Subject: fixes #32 autoscale based on CPUs available This should work on both Windows and the most common POSIX variants. We will create at least two threads for running completions, but there are numerous other threads in the code. --- src/core/taskq.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/core/taskq.c') diff --git a/src/core/taskq.c b/src/core/taskq.c index ae66ec67..82a7456b 100644 --- a/src/core/taskq.c +++ b/src/core/taskq.c @@ -261,11 +261,14 @@ nni_task_fini(nni_task *task) int nni_taskq_sys_init(void) { - int rv; + int nthrs; - // XXX: Make the "16" = NCPUs * 2 - rv = nni_taskq_init(&nni_taskq_systq, 16); - return (rv); + nthrs = nni_plat_ncpu() * 2; + if (nthrs < 2) { + nthrs = 2; + } + + return (nni_taskq_init(&nni_taskq_systq, nthrs)); } void -- cgit v1.2.3-70-g09d2