Commit 26ca9896 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

#2969 set cpu affinity in the keyrange-unflat test in an attempt to understand...

#2969 set cpu affinity in the keyrange-unflat test in an attempt to understand its performance refs[t:2969]

git-svn-id: file:///svn/toku/tokudb@24517 c7de825b-a66e-492c-adef-691d508d4ae1
parent fb2462e4
...@@ -21,6 +21,8 @@ static void test_flat (void) { ...@@ -21,6 +21,8 @@ static void test_flat (void) {
r = toku_open_brt(fname, 1, &t, 1<<12, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0); r = toku_open_brt(fname, 1, &t, 1<<12, ct, null_txn, toku_builtin_compare_fun, null_db); assert(r==0);
u_int64_t i; u_int64_t i;
// permute the numbers from 0 (inclusive) to limit (exclusive) // permute the numbers from 0 (inclusive) to limit (exclusive)
time_t now;
now = time(0); fprintf(stderr, "%.24s permute\n", ctime(&now));
permute[0]=0; permute[0]=0;
for (i=1; i<limit; i++) { for (i=1; i<limit; i++) {
permute[i]=i; permute[i]=i;
...@@ -28,6 +30,7 @@ static void test_flat (void) { ...@@ -28,6 +30,7 @@ static void test_flat (void) {
permute[i]=permute[ra]; permute[i]=permute[ra];
permute[ra]=i; permute[ra]=i;
} }
now = time(0); fprintf(stderr, "%.24s insert\n", ctime(&now));
for (i=0; i<limit; i++) { for (i=0; i<limit; i++) {
if (verbose) printf("%s:%d %"PRIu64"\n", __FUNCTION__, __LINE__, i); if (verbose) printf("%s:%d %"PRIu64"\n", __FUNCTION__, __LINE__, i);
char key[100],val[100]; char key[100],val[100];
...@@ -41,6 +44,7 @@ static void test_flat (void) { ...@@ -41,6 +44,7 @@ static void test_flat (void) {
// Don't flatten it. // Don't flatten it.
// search for the items that are there and those that aren't. // search for the items that are there and those that aren't.
// //
now = time(0); fprintf(stderr, "%.24s keyrange\n", ctime(&now));
u_int64_t prevless=0; u_int64_t prevless=0;
u_int64_t prevgreater=limit; u_int64_t prevgreater=limit;
for (i=0; i<2*limit+1; i++) { for (i=0; i<2*limit+1; i++) {
...@@ -56,13 +60,48 @@ static void test_flat (void) { ...@@ -56,13 +60,48 @@ static void test_flat (void) {
assert(less>=prevless); prevless = less; assert(less>=prevless); prevless = less;
assert(greater<=prevgreater); prevgreater = greater; assert(greater<=prevgreater); prevgreater = greater;
} }
now = time(0); fprintf(stderr, "%.24s done\n", ctime(&now));
r = toku_close_brt(t, 0); assert(r==0); r = toku_close_brt(t, 0); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
} }
int int
test_main (int argc , const char *argv[]) { test_main (int argc , const char *argv[]) {
#define DO_AFFINITY 0
#if DO_AFFINITY == 0
default_parse_args(argc, argv); default_parse_args(argc, argv);
#else
#include <sched.h>
int ncpus = 0;
for (int i = 1; i < argc; i++) {
const char *arg = argv[i];
if (strcmp(arg, "-v") == 0) {
verbose++;
continue;
}
if (strcmp(arg, "--ncpus") == 0 && i+1 < argc) {
ncpus = atoi(argv[++i]);
continue;
}
break;
}
if (ncpus > 0) {
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
for (int i = 0; i < ncpus; i++)
CPU_SET(i, &cpuset);
int r;
r = sched_setaffinity(toku_os_getpid(), sizeof cpuset, &cpuset);
assert(r == 0);
cpu_set_t use_cpuset;
CPU_ZERO(&use_cpuset);
r = sched_getaffinity(toku_os_getpid(), sizeof use_cpuset, &use_cpuset);
assert(r == 0);
assert(memcmp(&cpuset, &use_cpuset, sizeof cpuset) == 0);
}
#endif
test_flat(); test_flat();
......
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