mirror of
https://github.com/MariaDB/server.git
synced 2025-02-02 12:01:42 +01:00
#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
This commit is contained in:
parent
17eccfed9b
commit
22ae678c4a
1 changed files with 18 additions and 14 deletions
|
@ -62,24 +62,28 @@ 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;
|
cpu_set_t cpuset;
|
||||||
int r = sched_getaffinity(getpid(), sizeof cpuset, &cpuset);
|
int r = sched_getaffinity(getpid(), sizeof cpuset, &cpuset);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
int nn = 0;
|
int ncpus = 0;
|
||||||
for (unsigned i = 0; i < 8 * sizeof cpuset; i++)
|
for (unsigned i = 0; i < 8 * sizeof cpuset; i++)
|
||||||
if (CPU_ISSET(i, &cpuset))
|
if (CPU_ISSET(i, &cpuset))
|
||||||
nn++;
|
ncpus++;
|
||||||
assert(nn <= n);
|
assert(ncpus <= n);
|
||||||
n = nn;
|
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");
|
char *toku_ncpus = getenv("TOKU_NCPUS");
|
||||||
if (toku_ncpus) {
|
if (toku_ncpus) {
|
||||||
int ncpus = atoi(toku_ncpus);
|
int ncpus = atoi(toku_ncpus);
|
||||||
if (ncpus < n)
|
if (ncpus < n)
|
||||||
n = ncpus;
|
n = ncpus;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue