diff options
author | John Hawthorn <john.hawthorn@gmail.com> | 2016-06-22 21:43:48 -0700 |
---|---|---|
committer | John Hawthorn <john.hawthorn@gmail.com> | 2016-06-22 21:43:48 -0700 |
commit | 2142a44bf01d827c3a6f0b02f06b92d993a3fed6 (patch) | |
tree | 55e3f905ac951b8ed1c25f8168ff69f89f3bb7a5 /src/choices.c | |
parent | 471431c3d75eb4df127f22f1e1175bc43cd66549 (diff) |
Use number of processors as worker count
Since we're dividing the search set equally between processors, we want
to run with the same number of workers that we have CPU execution
threads. This avoids having a worker which is starved until the end of
execution.
Diffstat (limited to 'src/choices.c')
-rw-r--r-- | src/choices.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/choices.c b/src/choices.c index 70fc679..c935067 100644 --- a/src/choices.c +++ b/src/choices.c @@ -2,6 +2,7 @@ #include <stdio.h> #include <string.h> #include <pthread.h> +#include <unistd.h> #include "choices.h" #include "match.h" @@ -104,7 +105,7 @@ void choices_init(choices_t *c) { c->capacity = c->size = 0; choices_resize(c, INITIAL_CHOICE_CAPACITY); - c->worker_count = 8; + c->worker_count = (int)sysconf(_SC_NPROCESSORS_ONLN); choices_reset_search(c); } |