Commit eb40534d authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

#2513 rewrite the computation of the number of cpus refs[t:2513]

git-svn-id: file:///svn/toku/tokudb@24901 c7de825b-a66e-492c-adef-691d508d4ae1
parent 05ee9f03
...@@ -62,23 +62,27 @@ toku_os_get_number_active_processors(void) { ...@@ -62,23 +62,27 @@ toku_os_get_number_active_processors(void) {
#define DO_AFFINITY 1 #define DO_AFFINITY 1
#if DO_AFFINITY #if DO_AFFINITY
#include <sched.h> #include <sched.h>
cpu_set_t cpuset; {
int r = sched_getaffinity(getpid(), sizeof cpuset, &cpuset); cpu_set_t cpuset;
assert(r == 0); int r = sched_getaffinity(getpid(), sizeof cpuset, &cpuset);
int nn = 0; assert(r == 0);
for (unsigned i = 0; i < 8 * sizeof cpuset; i++) int ncpus = 0;
if (CPU_ISSET(i, &cpuset)) for (unsigned i = 0; i < 8 * sizeof cpuset; i++)
nn++; if (CPU_ISSET(i, &cpuset))
assert(nn <= n); ncpus++;
n = nn; assert(ncpus <= n);
n = ncpus;
}
#endif #endif
#define DO_TOKU_NCPUS 1 #define DO_TOKU_NCPUS 1
#if DO_TOKU_NCPUS #if DO_TOKU_NCPUS
char *toku_ncpus = getenv("TOKU_NCPUS"); {
if (toku_ncpus) { char *toku_ncpus = getenv("TOKU_NCPUS");
int ncpus = atoi(toku_ncpus); if (toku_ncpus) {
if (ncpus < n) int ncpus = atoi(toku_ncpus);
n = ncpus; if (ncpus < n)
n = ncpus;
}
} }
#endif #endif
return n; return n;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment