Browse code

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.

John Hawthorn authored on 23/06/2016 04:43:48
Showing 1 changed files

... ...
@@ -2,6 +2,7 @@
2 2
 #include <stdio.h>
3 3
 #include <string.h>
4 4
 #include <pthread.h>
5
+#include <unistd.h>
5 6
 
6 7
 #include "choices.h"
7 8
 #include "match.h"
... ...
@@ -104,7 +105,7 @@ void choices_init(choices_t *c) {
104 105
 	c->capacity = c->size = 0;
105 106
 	choices_resize(c, INITIAL_CHOICE_CAPACITY);
106 107
 
107
-	c->worker_count = 8;
108
+	c->worker_count = (int)sysconf(_SC_NPROCESSORS_ONLN);
108 109
 
109 110
 	choices_reset_search(c);
110 111
 }