Commit 2b8d2634 authored by Yoni Fogel's avatar Yoni Fogel

[t:5027] Made cli_args accessible through args. Removed redundant variables.

git-svn-id: file:///svn/toku/tokudb@44373 c7de825b-a66e-492c-adef-691d508d4ae1
parent 5574a100
...@@ -124,7 +124,7 @@ static void checkpoint_callback_2(void * extra) { ...@@ -124,7 +124,7 @@ static void checkpoint_callback_2(void * extra) {
// //
static int checkpoint_var(DB_TXN *txn, ARG arg, void* operation_extra, void *stats_extra) { static int checkpoint_var(DB_TXN *txn, ARG arg, void* operation_extra, void *stats_extra) {
int db_index = random()%arg->num_DBs; int db_index = random() % arg->cli->num_DBs;
int r = 0; int r = 0;
int val_size = *(int *)operation_extra; int val_size = *(int *)operation_extra;
DB* db = arg->dbp[db_index]; DB* db = arg->dbp[db_index];
...@@ -138,7 +138,7 @@ static int checkpoint_var(DB_TXN *txn, ARG arg, void* operation_extra, void *sta ...@@ -138,7 +138,7 @@ static int checkpoint_var(DB_TXN *txn, ARG arg, void* operation_extra, void *sta
increment_counter(stats_extra, PTQUERIES, i); increment_counter(stats_extra, PTQUERIES, i);
for (i = 0; i < 20; i++) { for (i = 0; i < 20; i++) {
// do a random insertion // do a random insertion
int rand_key = random() % arg->num_elements; int rand_key = random() % arg->cli->num_elements;
DBT key, val; DBT key, val;
r = db->put( r = db->put(
db, db,
...@@ -160,7 +160,6 @@ static void ...@@ -160,7 +160,6 @@ static void
stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) { stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) {
db_env_set_checkpoint_callback(checkpoint_callback_1, env); db_env_set_checkpoint_callback(checkpoint_callback_1, env);
db_env_set_checkpoint_callback2(checkpoint_callback_2, env); db_env_set_checkpoint_callback2(checkpoint_callback_2, env);
int n = cli_args->num_elements;
// //
// the threads that we want: // the threads that we want:
// - some threads constantly updating random values // - some threads constantly updating random values
...@@ -174,11 +173,10 @@ stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) { ...@@ -174,11 +173,10 @@ stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) {
const int num_threads = cli_args->num_ptquery_threads; const int num_threads = cli_args->num_ptquery_threads;
struct arg myargs[num_threads]; struct arg myargs[num_threads];
for (int i = 0; i < num_threads; i++) { for (int i = 0; i < num_threads; i++) {
arg_init(&myargs[i], n, dbp, env, cli_args); arg_init(&myargs[i], dbp, env, cli_args);
} }
for (int i = 0; i < num_threads; i++) { for (int i = 0; i < num_threads; i++) {
myargs[i].operation = checkpoint_var; myargs[i].operation = checkpoint_var;
myargs[i].crash_on_operation_failure = false;
myargs[i].operation_extra = &val_size; myargs[i].operation_extra = &val_size;
} }
run_workers(myargs, num_threads, cli_args->time_of_test, false, cli_args); run_workers(myargs, num_threads, cli_args->time_of_test, false, cli_args);
...@@ -190,6 +188,7 @@ test_main(int argc, char *const argv[]) { ...@@ -190,6 +188,7 @@ test_main(int argc, char *const argv[]) {
args.env_args.checkpointing_period = 30; args.env_args.checkpointing_period = 30;
args.num_DBs = 4; args.num_DBs = 4;
args.num_ptquery_threads = 4; args.num_ptquery_threads = 4;
args.crash_on_operation_failure = false;
parse_stress_test_args(argc, argv, &args); parse_stress_test_args(argc, argv, &args);
stress_test_main(&args); stress_test_main(&args);
return 0; return 0;
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
static void static void
stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) { stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) {
int n = cli_args->num_elements;
// //
// the threads that we want: // the threads that we want:
// - some threads constantly updating random values // - some threads constantly updating random values
...@@ -33,9 +32,7 @@ stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) { ...@@ -33,9 +32,7 @@ stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) {
const int num_threads = cli_args->num_ptquery_threads; const int num_threads = cli_args->num_ptquery_threads;
struct arg myargs[num_threads]; struct arg myargs[num_threads];
for (int i = 0; i < num_threads; i++) { for (int i = 0; i < num_threads; i++) {
arg_init(&myargs[i], n, dbp, env, cli_args); arg_init(&myargs[i], dbp, env, cli_args);
}
for (int i = 0; i < num_threads; i++) {
myargs[i].operation = cursor_create_close_op; myargs[i].operation = cursor_create_close_op;
} }
run_workers(myargs, num_threads, cli_args->time_of_test, false, cli_args); run_workers(myargs, num_threads, cli_args->time_of_test, false, cli_args);
......
...@@ -21,14 +21,11 @@ ...@@ -21,14 +21,11 @@
static void static void
stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) { stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) {
int n = cli_args->num_elements;
if (verbose) printf("starting creation of pthreads\n"); if (verbose) printf("starting creation of pthreads\n");
const int num_threads = cli_args->num_put_threads; const int num_threads = cli_args->num_put_threads;
struct arg myargs[num_threads]; struct arg myargs[num_threads];
for (int i = 0; i < num_threads; i++) { for (int i = 0; i < num_threads; i++) {
arg_init(&myargs[i], n, dbp, env, cli_args); arg_init(&myargs[i], dbp, env, cli_args);
}
for (int i = 0; i < num_threads; i++) {
myargs[i].operation = random_put_op_singledb; myargs[i].operation = random_put_op_singledb;
} }
run_workers(myargs, num_threads, cli_args->time_of_test, false, cli_args); run_workers(myargs, num_threads, cli_args->time_of_test, false, cli_args);
......
...@@ -22,14 +22,11 @@ ...@@ -22,14 +22,11 @@
static void static void
stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) { stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) {
int n = cli_args->num_elements;
if (verbose) printf("starting creation of pthreads\n"); if (verbose) printf("starting creation of pthreads\n");
const int num_threads = cli_args->num_ptquery_threads; const int num_threads = cli_args->num_ptquery_threads;
struct arg myargs[num_threads]; struct arg myargs[num_threads];
for (int i = 0; i < num_threads; i++) { for (int i = 0; i < num_threads; i++) {
arg_init(&myargs[i], n, dbp, env, cli_args); arg_init(&myargs[i], dbp, env, cli_args);
}
for (int i = 0; i < num_threads; i++) {
myargs[i].operation = malloc_free_op; myargs[i].operation = malloc_free_op;
} }
run_workers(myargs, num_threads, cli_args->time_of_test, false, cli_args); run_workers(myargs, num_threads, cli_args->time_of_test, false, cli_args);
......
...@@ -20,14 +20,11 @@ ...@@ -20,14 +20,11 @@
static void static void
stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) { stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) {
int n = cli_args->num_elements;
if (verbose) printf("starting creation of pthreads\n"); if (verbose) printf("starting creation of pthreads\n");
const int num_threads = cli_args->num_ptquery_threads; const int num_threads = cli_args->num_ptquery_threads;
struct arg myargs[num_threads]; struct arg myargs[num_threads];
for (int i = 0; i < num_threads; i++) { for (int i = 0; i < num_threads; i++) {
arg_init(&myargs[i], n, dbp, env, cli_args); arg_init(&myargs[i], dbp, env, cli_args);
}
for (int i = 0; i < num_threads; i++) {
myargs[i].operation = nop; myargs[i].operation = nop;
} }
run_workers(myargs, num_threads, cli_args->time_of_test, false, cli_args); run_workers(myargs, num_threads, cli_args->time_of_test, false, cli_args);
......
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
static void static void
stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) { stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) {
int n = cli_args->num_elements;
// //
// the threads that we want: // the threads that we want:
// - some threads constantly updating random values // - some threads constantly updating random values
...@@ -53,9 +52,7 @@ stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) { ...@@ -53,9 +52,7 @@ stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) {
const int num_threads = cli_args->num_ptquery_threads; const int num_threads = cli_args->num_ptquery_threads;
struct arg myargs[num_threads]; struct arg myargs[num_threads];
for (int i = 0; i < num_threads; i++) { for (int i = 0; i < num_threads; i++) {
arg_init(&myargs[i], n, dbp, env, cli_args); arg_init(&myargs[i], dbp, env, cli_args);
}
for (int i = 0; i < num_threads; i++) {
myargs[i].operation = ptquery_op; myargs[i].operation = ptquery_op;
} }
run_workers(myargs, num_threads, cli_args->time_of_test, false, cli_args); run_workers(myargs, num_threads, cli_args->time_of_test, false, cli_args);
......
...@@ -50,7 +50,6 @@ static int ptquery_op2(DB_TXN *txn, ARG arg, void* operation_extra, void *stats_ ...@@ -50,7 +50,6 @@ static int ptquery_op2(DB_TXN *txn, ARG arg, void* operation_extra, void *stats_
static void static void
stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) { stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) {
int n = cli_args->num_elements;
// //
// the threads that we want: // the threads that we want:
// - some threads constantly updating random values // - some threads constantly updating random values
...@@ -64,9 +63,7 @@ stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) { ...@@ -64,9 +63,7 @@ stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) {
struct arg myargs[num_threads]; struct arg myargs[num_threads];
int thread_ids[num_threads]; int thread_ids[num_threads];
for (int i = 0; i < num_threads; i++) { for (int i = 0; i < num_threads; i++) {
arg_init(&myargs[i], n, dbp, env, cli_args); arg_init(&myargs[i], dbp, env, cli_args);
}
for (int i = 0; i < num_threads; i++) {
thread_ids[i] = i % cli_args->num_DBs; thread_ids[i] = i % cli_args->num_DBs;
myargs[i].operation = ptquery_op2; myargs[i].operation = ptquery_op2;
myargs[i].operation_extra = &thread_ids[i]; myargs[i].operation_extra = &thread_ids[i];
......
...@@ -20,14 +20,11 @@ ...@@ -20,14 +20,11 @@
static void static void
stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) { stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) {
int n = cli_args->num_elements;
if (verbose) printf("starting creation of pthreads\n"); if (verbose) printf("starting creation of pthreads\n");
const int num_threads = cli_args->num_ptquery_threads; const int num_threads = cli_args->num_ptquery_threads;
struct arg myargs[num_threads]; struct arg myargs[num_threads];
for (int i = 0; i < num_threads; i++) { for (int i = 0; i < num_threads; i++) {
arg_init(&myargs[i], n, dbp, env, cli_args); arg_init(&myargs[i], dbp, env, cli_args);
}
for (int i = 0; i < num_threads; i++) {
myargs[i].operation = xmalloc_free_op; myargs[i].operation = xmalloc_free_op;
} }
run_workers(myargs, num_threads, cli_args->time_of_test, false, cli_args); run_workers(myargs, num_threads, cli_args->time_of_test, false, cli_args);
......
...@@ -46,8 +46,6 @@ static void flt_callback(int flt_state, void* extra) { ...@@ -46,8 +46,6 @@ static void flt_callback(int flt_state, void* extra) {
static void static void
stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) { stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
int n = cli_args->num_elements;
// //
// the threads that we want: // the threads that we want:
// - one thread constantly updating random values // - one thread constantly updating random values
...@@ -60,7 +58,7 @@ stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) { ...@@ -60,7 +58,7 @@ stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
const int num_threads = 1; const int num_threads = 1;
struct arg myargs[num_threads]; struct arg myargs[num_threads];
for (int i = 0; i < num_threads; i++) { for (int i = 0; i < num_threads; i++) {
arg_init(&myargs[i], n, dbp, env, cli_args); arg_init(&myargs[i], dbp, env, cli_args);
} }
// make the guy that updates the db // make the guy that updates the db
......
...@@ -40,8 +40,6 @@ ...@@ -40,8 +40,6 @@
static void static void
stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) { stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
int n = cli_args->num_elements;
// //
// the threads that we want: // the threads that we want:
// - one thread constantly updating random values // - one thread constantly updating random values
...@@ -54,7 +52,7 @@ stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) { ...@@ -54,7 +52,7 @@ stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
const int num_threads = 4 + cli_args->num_update_threads + cli_args->num_ptquery_threads; const int num_threads = 4 + cli_args->num_update_threads + cli_args->num_ptquery_threads;
struct arg myargs[num_threads]; struct arg myargs[num_threads];
for (int i = 0; i < num_threads; i++) { for (int i = 0; i < num_threads; i++) {
arg_init(&myargs[i], n, dbp, env, cli_args); arg_init(&myargs[i], dbp, env, cli_args);
} }
struct scan_op_extra soe[4]; struct scan_op_extra soe[4];
......
...@@ -18,15 +18,13 @@ ...@@ -18,15 +18,13 @@
static void static void
stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) { stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
int n = cli_args->num_elements;
if (verbose) printf("starting creation of pthreads\n"); if (verbose) printf("starting creation of pthreads\n");
const int num_threads = cli_args->num_update_threads; const int num_threads = cli_args->num_update_threads;
struct arg myargs[num_threads]; struct arg myargs[num_threads];
struct update_op_args uoe = get_update_op_args(cli_args, NULL); struct update_op_args uoe = get_update_op_args(cli_args, NULL);
// make the guy that updates the db // make the guy that updates the db
for (int i = 0; i < 0 + cli_args->num_update_threads; ++i) { for (int i = 0; i < 0 + cli_args->num_update_threads; ++i) {
arg_init(&myargs[i], n, dbp, env, cli_args); arg_init(&myargs[i], dbp, env, cli_args);
myargs[i].operation_extra = &uoe; myargs[i].operation_extra = &uoe;
myargs[i].operation = update_op; myargs[i].operation = update_op;
} }
......
...@@ -64,8 +64,6 @@ static int manual_checkpoint(DB_TXN *UU(txn), ARG UU(arg), void* operation_extra ...@@ -64,8 +64,6 @@ static int manual_checkpoint(DB_TXN *UU(txn), ARG UU(arg), void* operation_extra
static void static void
stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) { stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
int n = cli_args->num_elements;
// //
// the threads that we want: // the threads that we want:
// - one thread constantly updating random values // - one thread constantly updating random values
...@@ -78,7 +76,7 @@ stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) { ...@@ -78,7 +76,7 @@ stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
const int num_threads = 5 + cli_args->num_update_threads + cli_args->num_ptquery_threads; const int num_threads = 5 + cli_args->num_update_threads + cli_args->num_ptquery_threads;
struct arg myargs[num_threads]; struct arg myargs[num_threads];
for (int i = 0; i < num_threads; i++) { for (int i = 0; i < num_threads; i++) {
arg_init(&myargs[i], n, dbp, env, cli_args); arg_init(&myargs[i], dbp, env, cli_args);
} }
struct scan_op_extra soe[4]; struct scan_op_extra soe[4];
......
...@@ -26,14 +26,11 @@ static int random_sleep(DB_TXN* UU(txn), ARG UU(arg), void* UU(operation_extra), ...@@ -26,14 +26,11 @@ static int random_sleep(DB_TXN* UU(txn), ARG UU(arg), void* UU(operation_extra),
static void static void
stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) { stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) {
int n = cli_args->num_elements;
if (verbose) printf("starting creation of pthreads\n"); if (verbose) printf("starting creation of pthreads\n");
const int num_threads = cli_args->num_ptquery_threads; const int num_threads = cli_args->num_ptquery_threads;
struct arg myargs[num_threads]; struct arg myargs[num_threads];
for (int i = 0; i < num_threads; i++) { for (int i = 0; i < num_threads; i++) {
arg_init(&myargs[i], n, dbp, env, cli_args); arg_init(&myargs[i], dbp, env, cli_args);
}
for (int i = 0; i < num_threads; i++) {
myargs[i].operation = random_sleep; myargs[i].operation = random_sleep;
} }
run_workers(myargs, num_threads, cli_args->time_of_test, false, cli_args); run_workers(myargs, num_threads, cli_args->time_of_test, false, cli_args);
......
...@@ -40,8 +40,6 @@ ...@@ -40,8 +40,6 @@
static void static void
stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) { stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
int n = cli_args->num_elements;
// //
// the threads that we want: // the threads that we want:
// - some threads constantly updating random values // - some threads constantly updating random values
...@@ -54,7 +52,7 @@ stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) { ...@@ -54,7 +52,7 @@ stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
const int num_threads = 4 + cli_args->num_update_threads + cli_args->num_ptquery_threads; const int num_threads = 4 + cli_args->num_update_threads + cli_args->num_ptquery_threads;
struct arg myargs[num_threads]; struct arg myargs[num_threads];
for (int i = 0; i < num_threads; i++) { for (int i = 0; i < num_threads; i++) {
arg_init(&myargs[i], n, dbp, env, cli_args); arg_init(&myargs[i], dbp, env, cli_args);
} }
struct scan_op_extra soe[4]; struct scan_op_extra soe[4];
......
...@@ -34,8 +34,6 @@ ...@@ -34,8 +34,6 @@
static void static void
stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) { stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
int n = cli_args->num_elements;
// //
// the threads that we want: // the threads that we want:
// - one thread constantly updating random values // - one thread constantly updating random values
...@@ -48,7 +46,7 @@ stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) { ...@@ -48,7 +46,7 @@ stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
const int num_threads = 4 + cli_args->num_update_threads + cli_args->num_ptquery_threads; const int num_threads = 4 + cli_args->num_update_threads + cli_args->num_ptquery_threads;
struct arg myargs[num_threads]; struct arg myargs[num_threads];
for (int i = 0; i < num_threads; i++) { for (int i = 0; i < num_threads; i++) {
arg_init(&myargs[i], n, dbp, env, cli_args); arg_init(&myargs[i], dbp, env, cli_args);
} }
struct scan_op_extra soe[4]; struct scan_op_extra soe[4];
......
...@@ -33,8 +33,6 @@ ...@@ -33,8 +33,6 @@
static void static void
stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) { stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
int n = cli_args->num_elements;
// //
// the threads that we want: // the threads that we want:
// - one thread constantly updating random values // - one thread constantly updating random values
...@@ -46,7 +44,7 @@ stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) { ...@@ -46,7 +44,7 @@ stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
const int num_threads = 5 + cli_args->num_update_threads + cli_args->num_ptquery_threads; const int num_threads = 5 + cli_args->num_update_threads + cli_args->num_ptquery_threads;
struct arg myargs[num_threads]; struct arg myargs[num_threads];
for (int i = 0; i < num_threads; i++) { for (int i = 0; i < num_threads; i++) {
arg_init(&myargs[i], n, dbp, env, cli_args); arg_init(&myargs[i], dbp, env, cli_args);
} }
struct scan_op_extra soe[4]; struct scan_op_extra soe[4];
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
static void static void
stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) { stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
int n = cli_args->num_elements; int n = cli_args->num_elements;
// //
// the threads that we want: // the threads that we want:
// - one thread constantly updating random values // - one thread constantly updating random values
...@@ -46,7 +45,7 @@ stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) { ...@@ -46,7 +45,7 @@ stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
const int num_threads = 4 + cli_args->num_update_threads + cli_args->num_ptquery_threads; const int num_threads = 4 + cli_args->num_update_threads + cli_args->num_ptquery_threads;
struct arg myargs[num_threads]; struct arg myargs[num_threads];
for (int i = 0; i < num_threads; i++) { for (int i = 0; i < num_threads; i++) {
arg_init(&myargs[i], n, dbp, env, cli_args); arg_init(&myargs[i], dbp, env, cli_args);
} }
struct scan_op_extra soe[4]; struct scan_op_extra soe[4];
......
...@@ -18,8 +18,6 @@ ...@@ -18,8 +18,6 @@
static void static void
stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) { stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
int n = cli_args->num_elements;
// //
// do insertions and queries with a loader lying around doing stuff // do insertions and queries with a loader lying around doing stuff
// //
...@@ -28,7 +26,7 @@ stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) { ...@@ -28,7 +26,7 @@ stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
const int num_threads = 4 + cli_args->num_update_threads + cli_args->num_ptquery_threads; const int num_threads = 4 + cli_args->num_update_threads + cli_args->num_ptquery_threads;
struct arg myargs[num_threads]; struct arg myargs[num_threads];
for (int i = 0; i < num_threads; i++) { for (int i = 0; i < num_threads; i++) {
arg_init(&myargs[i], n, dbp, env, cli_args); arg_init(&myargs[i], dbp, env, cli_args);
} }
struct scan_op_extra soe[2]; struct scan_op_extra soe[2];
......
...@@ -34,8 +34,6 @@ ...@@ -34,8 +34,6 @@
static void static void
stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) { stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
int n = cli_args->num_elements;
// //
// the threads that we want: // the threads that we want:
// - one thread constantly updating random values // - one thread constantly updating random values
...@@ -48,7 +46,7 @@ stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) { ...@@ -48,7 +46,7 @@ stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
const int num_threads = 5 + cli_args->num_update_threads + cli_args->num_ptquery_threads; const int num_threads = 5 + cli_args->num_update_threads + cli_args->num_ptquery_threads;
struct arg myargs[num_threads]; struct arg myargs[num_threads];
for (int i = 0; i < num_threads; i++) { for (int i = 0; i < num_threads; i++) {
arg_init(&myargs[i], n, dbp, env, cli_args); arg_init(&myargs[i], dbp, env, cli_args);
} }
struct scan_op_extra soe[4]; struct scan_op_extra soe[4];
......
...@@ -18,8 +18,6 @@ ...@@ -18,8 +18,6 @@
static void static void
stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) { stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
int n = cli_args->num_elements;
// //
// do insertions and queries with a loader lying around doing stuff // do insertions and queries with a loader lying around doing stuff
// //
...@@ -28,7 +26,7 @@ stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) { ...@@ -28,7 +26,7 @@ stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
const int num_threads = 4 + cli_args->num_update_threads + cli_args->num_ptquery_threads; const int num_threads = 4 + cli_args->num_update_threads + cli_args->num_ptquery_threads;
struct arg myargs[num_threads]; struct arg myargs[num_threads];
for (int i = 0; i < num_threads; i++) { for (int i = 0; i < num_threads; i++) {
arg_init(&myargs[i], n, dbp, env, cli_args); arg_init(&myargs[i], dbp, env, cli_args);
} }
struct scan_op_extra soe[2]; struct scan_op_extra soe[2];
......
...@@ -24,8 +24,6 @@ ...@@ -24,8 +24,6 @@
static void static void
stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) { stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
int n = cli_args->num_elements;
// //
// do insertions and queries with a loader lying around doing stuff // do insertions and queries with a loader lying around doing stuff
// //
...@@ -34,7 +32,7 @@ stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) { ...@@ -34,7 +32,7 @@ stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
const int num_threads = 4 + cli_args->num_update_threads + cli_args->num_ptquery_threads; const int num_threads = 4 + cli_args->num_update_threads + cli_args->num_ptquery_threads;
struct arg myargs[num_threads]; struct arg myargs[num_threads];
for (int i = 0; i < num_threads; i++) { for (int i = 0; i < num_threads; i++) {
arg_init(&myargs[i], n, dbp, env, cli_args); arg_init(&myargs[i], dbp, env, cli_args);
} }
// make the forward fast scanner // make the forward fast scanner
struct scan_op_extra soe; struct scan_op_extra soe;
......
...@@ -100,28 +100,6 @@ enum stress_lock_type { ...@@ -100,28 +100,6 @@ enum stress_lock_type {
STRESS_LOCK_EXCL STRESS_LOCK_EXCL
}; };
struct arg {
int num_elements; // number of elements per DB
DB **dbp; // array of DBs
int num_DBs; // number of DBs
DB_ENV* env; // environment used
bool bounded_element_range; // true if elements in dictionary are bounded
// by num_elements, that is, all keys in each
// DB are in [0, num_elements)
// false otherwise
int sleep_ms; // number of milliseconds to sleep between operations
u_int32_t txn_type; // isolation level for txn running operation
operation_t operation; // function that is the operation to be run
void* operation_extra; // extra parameter passed to operation
enum stress_lock_type lock_type; // states if operation must be exclusive, shared, or does not require locking
bool crash_on_operation_failure; // true if we should crash if operation returns non-zero, false otherwise
struct random_data *random_data; // state for random_r
u_int32_t txn_size; // specifies number of updates/puts/whatevers per txn
bool single_txn;
int thread_idx;
int num_threads;
};
struct env_args { struct env_args {
int node_size; int node_size;
int basement_node_size; int basement_node_size;
...@@ -150,7 +128,7 @@ struct cli_args { ...@@ -150,7 +128,7 @@ struct cli_args {
bool do_recover; // true if we should run recover bool do_recover; // true if we should run recover
int num_update_threads; // number of threads running updates int num_update_threads; // number of threads running updates
int num_put_threads; // number of threads running puts int num_put_threads; // number of threads running puts
bool crash_on_update_failure; bool crash_on_operation_failure;
bool print_performance; bool print_performance;
bool print_thread_performance; bool print_thread_performance;
enum perf_output_format perf_output_format; enum perf_output_format perf_output_format;
...@@ -163,20 +141,34 @@ struct cli_args { ...@@ -163,20 +141,34 @@ struct cli_args {
bool warm_cache; // warm caches before running stress_table bool warm_cache; // warm caches before running stress_table
}; };
struct arg {
DB **dbp; // array of DBs
DB_ENV* env; // environment used
bool bounded_element_range; // true if elements in dictionary are bounded
// by num_elements, that is, all keys in each
// DB are in [0, num_elements)
// false otherwise
int sleep_ms; // number of milliseconds to sleep between operations
u_int32_t txn_type; // isolation level for txn running operation
operation_t operation; // function that is the operation to be run
void* operation_extra; // extra parameter passed to operation
enum stress_lock_type lock_type; // states if operation must be exclusive, shared, or does not require locking
struct random_data *random_data; // state for random_r
int thread_idx;
int num_threads;
struct cli_args *cli;
};
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
static void arg_init(struct arg *arg, int num_elements, DB **dbp, DB_ENV *env, struct cli_args *cli_args) { static void arg_init(struct arg *arg, DB **dbp, DB_ENV *env, struct cli_args *cli_args) {
arg->num_elements = num_elements; arg->cli = cli_args;
arg->dbp = dbp; arg->dbp = dbp;
arg->num_DBs = cli_args->num_DBs;
arg->env = env; arg->env = env;
arg->bounded_element_range = true; arg->bounded_element_range = true;
arg->sleep_ms = 0; arg->sleep_ms = 0;
arg->lock_type = STRESS_LOCK_NONE; arg->lock_type = STRESS_LOCK_NONE;
arg->txn_type = DB_TXN_SNAPSHOT; arg->txn_type = DB_TXN_SNAPSHOT;
arg->crash_on_operation_failure = cli_args->crash_on_update_failure;
arg->txn_size = cli_args->txn_size;
arg->single_txn = cli_args->single_txn;
arg->operation_extra = NULL; arg->operation_extra = NULL;
} }
...@@ -393,24 +385,24 @@ static void *worker(void *arg_v) { ...@@ -393,24 +385,24 @@ static void *worker(void *arg_v) {
if (verbose) { if (verbose) {
printf("%lu starting %p\n", (unsigned long) toku_pthread_self(), arg->operation); printf("%lu starting %p\n", (unsigned long) toku_pthread_self(), arg->operation);
} }
if (arg->single_txn) { if (arg->cli->single_txn) {
r = env->txn_begin(env, 0, &txn, arg->txn_type); CKERR(r); r = env->txn_begin(env, 0, &txn, arg->txn_type); CKERR(r);
} }
while (run_test) { while (run_test) {
lock_worker_op(we); lock_worker_op(we);
if (!arg->single_txn) { if (!arg->cli->single_txn) {
r = env->txn_begin(env, 0, &txn, arg->txn_type); CKERR(r); r = env->txn_begin(env, 0, &txn, arg->txn_type); CKERR(r);
} }
r = arg->operation(txn, arg, arg->operation_extra, we->counters); r = arg->operation(txn, arg, arg->operation_extra, we->counters);
if (r == 0) { if (r == 0) {
if (!arg->single_txn) { if (!arg->cli->single_txn) {
CHK(txn->commit(txn,0)); CHK(txn->commit(txn,0));
} }
} else { } else {
if (arg->crash_on_operation_failure) { if (arg->cli->crash_on_operation_failure) {
CKERR(r); CKERR(r);
} else { } else {
if (!arg->single_txn) { if (!arg->cli->single_txn) {
CHK(txn->abort(txn)); CHK(txn->abort(txn));
} }
} }
...@@ -421,7 +413,7 @@ static void *worker(void *arg_v) { ...@@ -421,7 +413,7 @@ static void *worker(void *arg_v) {
usleep(arg->sleep_ms * 1000); usleep(arg->sleep_ms * 1000);
} }
} }
if (arg->single_txn) { if (arg->cli->single_txn) {
CHK(txn->commit(txn, 0)); CHK(txn->commit(txn, 0));
} }
if (verbose) if (verbose)
...@@ -538,7 +530,7 @@ static int random_put_in_db(DB *db, DB_TXN *txn, ARG arg, void *stats_extra) { ...@@ -538,7 +530,7 @@ static int random_put_in_db(DB *db, DB_TXN *txn, ARG arg, void *stats_extra) {
char buf[100]; char buf[100];
ZERO_ARRAY(buf); ZERO_ARRAY(buf);
uint64_t i; uint64_t i;
for (i = 0; i < arg->txn_size; ++i) { for (i = 0; i < arg->cli->txn_size; ++i) {
union { union {
uint64_t key; uint64_t key;
uint16_t i[4]; uint16_t i[4];
...@@ -559,13 +551,13 @@ cleanup: ...@@ -559,13 +551,13 @@ cleanup:
} }
static int UU() random_put_op(DB_TXN *txn, ARG arg, void *UU(operation_extra), void *stats_extra) { static int UU() random_put_op(DB_TXN *txn, ARG arg, void *UU(operation_extra), void *stats_extra) {
int db_index = myrandom_r(arg->random_data)%arg->num_DBs; int db_index = myrandom_r(arg->random_data)%arg->cli->num_DBs;
DB* db = arg->dbp[db_index]; DB* db = arg->dbp[db_index];
return random_put_in_db(db, txn, arg, stats_extra); return random_put_in_db(db, txn, arg, stats_extra);
} }
static int UU() random_put_op_singledb(DB_TXN *txn, ARG arg, void *UU(operation_extra), void *stats_extra) { static int UU() random_put_op_singledb(DB_TXN *txn, ARG arg, void *UU(operation_extra), void *stats_extra) {
int db_index = arg->thread_idx%arg->num_DBs; int db_index = arg->thread_idx%arg->cli->num_DBs;
DB* db = arg->dbp[db_index]; DB* db = arg->dbp[db_index];
return random_put_in_db(db, txn, arg, stats_extra); return random_put_in_db(db, txn, arg, stats_extra);
} }
...@@ -607,11 +599,11 @@ static int UU() keyrange_op(DB_TXN *txn, ARG arg, void* UU(operation_extra), voi ...@@ -607,11 +599,11 @@ static int UU() keyrange_op(DB_TXN *txn, ARG arg, void* UU(operation_extra), voi
// callback is designed to run on tests with one DB // callback is designed to run on tests with one DB
// no particular reason why, just the way it was // no particular reason why, just the way it was
// originally done // originally done
int db_index = myrandom_r(arg->random_data)%arg->num_DBs; int db_index = myrandom_r(arg->random_data)%arg->cli->num_DBs;
DB* db = arg->dbp[db_index]; DB* db = arg->dbp[db_index];
int rand_key = myrandom_r(arg->random_data); int rand_key = myrandom_r(arg->random_data);
if (arg->bounded_element_range) { if (arg->bounded_element_range) {
rand_key = rand_key % arg->num_elements; rand_key = rand_key % arg->cli->num_elements;
} }
DBT key; DBT key;
dbt_init(&key, &rand_key, sizeof rand_key); dbt_init(&key, &rand_key, sizeof rand_key);
...@@ -624,7 +616,7 @@ static int UU() keyrange_op(DB_TXN *txn, ARG arg, void* UU(operation_extra), voi ...@@ -624,7 +616,7 @@ static int UU() keyrange_op(DB_TXN *txn, ARG arg, void* UU(operation_extra), voi
static int UU() verify_op(DB_TXN* UU(txn), ARG UU(arg), void* UU(operation_extra), void *UU(stats_extra)) { static int UU() verify_op(DB_TXN* UU(txn), ARG UU(arg), void* UU(operation_extra), void *UU(stats_extra)) {
int r = 0; int r = 0;
for (int i = 0; i < arg->num_DBs; i++) { for (int i = 0; i < arg->cli->num_DBs; i++) {
DB* db = arg->dbp[i]; DB* db = arg->dbp[i];
r = db->verify_with_progress(db, NULL, NULL, 0, 0); r = db->verify_with_progress(db, NULL, NULL, 0, 0);
CKERR(r); CKERR(r);
...@@ -634,7 +626,7 @@ static int UU() verify_op(DB_TXN* UU(txn), ARG UU(arg), void* UU(operation_extra ...@@ -634,7 +626,7 @@ static int UU() verify_op(DB_TXN* UU(txn), ARG UU(arg), void* UU(operation_extra
static int UU() scan_op(DB_TXN *txn, ARG UU(arg), void* operation_extra, void *UU(stats_extra)) { static int UU() scan_op(DB_TXN *txn, ARG UU(arg), void* operation_extra, void *UU(stats_extra)) {
struct scan_op_extra* extra = operation_extra; struct scan_op_extra* extra = operation_extra;
for (int i = 0; i < arg->num_DBs; i++) { for (int i = 0; i < arg->cli->num_DBs; i++) {
int r = scan_op_and_maybe_check_sum(arg->dbp[i], txn, extra, true); int r = scan_op_and_maybe_check_sum(arg->dbp[i], txn, extra, true);
assert_zero(r); assert_zero(r);
} }
...@@ -643,7 +635,7 @@ static int UU() scan_op(DB_TXN *txn, ARG UU(arg), void* operation_extra, void *U ...@@ -643,7 +635,7 @@ static int UU() scan_op(DB_TXN *txn, ARG UU(arg), void* operation_extra, void *U
static int UU() scan_op_no_check(DB_TXN *txn, ARG arg, void* operation_extra, void *UU(stats_extra)) { static int UU() scan_op_no_check(DB_TXN *txn, ARG arg, void* operation_extra, void *UU(stats_extra)) {
struct scan_op_extra* extra = operation_extra; struct scan_op_extra* extra = operation_extra;
for (int i = 0; i < arg->num_DBs; i++) { for (int i = 0; i < arg->cli->num_DBs; i++) {
int r = scan_op_and_maybe_check_sum(arg->dbp[i], txn, extra, false); int r = scan_op_and_maybe_check_sum(arg->dbp[i], txn, extra, false);
assert_zero(r); assert_zero(r);
} }
...@@ -654,7 +646,7 @@ static int UU() ptquery_and_maybe_check_op(DB* db, DB_TXN *txn, ARG arg, BOOL ch ...@@ -654,7 +646,7 @@ static int UU() ptquery_and_maybe_check_op(DB* db, DB_TXN *txn, ARG arg, BOOL ch
int r; int r;
int rand_key = myrandom_r(arg->random_data); int rand_key = myrandom_r(arg->random_data);
if (arg->bounded_element_range) { if (arg->bounded_element_range) {
rand_key = rand_key % arg->num_elements; rand_key = rand_key % arg->cli->num_elements;
} }
DBT key, val; DBT key, val;
dbt_init(&key, &rand_key, sizeof rand_key); dbt_init(&key, &rand_key, sizeof rand_key);
...@@ -666,7 +658,7 @@ static int UU() ptquery_and_maybe_check_op(DB* db, DB_TXN *txn, ARG arg, BOOL ch ...@@ -666,7 +658,7 @@ static int UU() ptquery_and_maybe_check_op(DB* db, DB_TXN *txn, ARG arg, BOOL ch
} }
static int UU() ptquery_op(DB_TXN *txn, ARG arg, void* UU(operation_extra), void *stats_extra) { static int UU() ptquery_op(DB_TXN *txn, ARG arg, void* UU(operation_extra), void *stats_extra) {
int db_index = myrandom_r(arg->random_data)%arg->num_DBs; int db_index = myrandom_r(arg->random_data)%arg->cli->num_DBs;
DB* db = arg->dbp[db_index]; DB* db = arg->dbp[db_index];
int r = ptquery_and_maybe_check_op(db, txn, arg, TRUE); int r = ptquery_and_maybe_check_op(db, txn, arg, TRUE);
if (!r) { if (!r) {
...@@ -676,7 +668,7 @@ static int UU() ptquery_op(DB_TXN *txn, ARG arg, void* UU(operation_extra), void ...@@ -676,7 +668,7 @@ static int UU() ptquery_op(DB_TXN *txn, ARG arg, void* UU(operation_extra), void
} }
static int UU() ptquery_op_no_check(DB_TXN *txn, ARG arg, void* UU(operation_extra), void *stats_extra) { static int UU() ptquery_op_no_check(DB_TXN *txn, ARG arg, void* UU(operation_extra), void *stats_extra) {
int db_index = myrandom_r(arg->random_data)%arg->num_DBs; int db_index = myrandom_r(arg->random_data)%arg->cli->num_DBs;
DB* db = arg->dbp[db_index]; DB* db = arg->dbp[db_index];
int r = ptquery_and_maybe_check_op(db, txn, arg, FALSE); int r = ptquery_and_maybe_check_op(db, txn, arg, FALSE);
if (!r) { if (!r) {
...@@ -686,7 +678,7 @@ static int UU() ptquery_op_no_check(DB_TXN *txn, ARG arg, void* UU(operation_ext ...@@ -686,7 +678,7 @@ static int UU() ptquery_op_no_check(DB_TXN *txn, ARG arg, void* UU(operation_ext
} }
static int UU() cursor_create_close_op(DB_TXN *txn, ARG arg, void* UU(operation_extra), void *UU(stats_extra)) { static int UU() cursor_create_close_op(DB_TXN *txn, ARG arg, void* UU(operation_extra), void *UU(stats_extra)) {
int db_index = arg->num_DBs > 1 ? myrandom_r(arg->random_data)%arg->num_DBs : 0; int db_index = arg->cli->num_DBs > 1 ? myrandom_r(arg->random_data)%arg->cli->num_DBs : 0;
DB* db = arg->dbp[db_index]; DB* db = arg->dbp[db_index];
DBC* cursor = NULL; DBC* cursor = NULL;
int r = db->cursor(db, txn, &cursor, 0); assert(r == 0); int r = db->cursor(db, txn, &cursor, 0); assert(r == 0);
...@@ -771,7 +763,7 @@ static int update_op_callback(DB *UU(db), const DBT *UU(key), ...@@ -771,7 +763,7 @@ static int update_op_callback(DB *UU(db), const DBT *UU(key),
static int UU()update_op2(DB_TXN* txn, ARG arg, void* UU(operation_extra), void *UU(stats_extra)) { static int UU()update_op2(DB_TXN* txn, ARG arg, void* UU(operation_extra), void *UU(stats_extra)) {
int r; int r;
int db_index = myrandom_r(arg->random_data)%arg->num_DBs; int db_index = myrandom_r(arg->random_data)%arg->cli->num_DBs;
DB* db = arg->dbp[db_index]; DB* db = arg->dbp[db_index];
int curr_val_sum = 0; int curr_val_sum = 0;
DBT key, val; DBT key, val;
...@@ -782,12 +774,12 @@ static int UU()update_op2(DB_TXN* txn, ARG arg, void* UU(operation_extra), void ...@@ -782,12 +774,12 @@ static int UU()update_op2(DB_TXN* txn, ARG arg, void* UU(operation_extra), void
ZERO_STRUCT(extra); ZERO_STRUCT(extra);
extra.type = UPDATE_ADD_DIFF; extra.type = UPDATE_ADD_DIFF;
extra.pad_bytes = 0; extra.pad_bytes = 0;
for (u_int32_t i = 0; i < arg->txn_size; i++) { for (u_int32_t i = 0; i < arg->cli->txn_size; i++) {
rand_key = myrandom_r(arg->random_data); rand_key = myrandom_r(arg->random_data);
if (arg->bounded_element_range) { if (arg->bounded_element_range) {
rand_key = rand_key % (arg->num_elements/2); rand_key = rand_key % (arg->cli->num_elements/2);
} }
rand_key2 = arg->num_elements - rand_key; rand_key2 = arg->cli->num_elements - rand_key;
assert(rand_key != rand_key2); assert(rand_key != rand_key2);
extra.u.d.diff = 1; extra.u.d.diff = 1;
curr_val_sum += extra.u.d.diff; curr_val_sum += extra.u.d.diff;
...@@ -818,7 +810,7 @@ static int UU()update_op2(DB_TXN* txn, ARG arg, void* UU(operation_extra), void ...@@ -818,7 +810,7 @@ static int UU()update_op2(DB_TXN* txn, ARG arg, void* UU(operation_extra), void
static int UU()update_op(DB_TXN *txn, ARG arg, void* operation_extra, void *UU(stats_extra)) { static int UU()update_op(DB_TXN *txn, ARG arg, void* operation_extra, void *UU(stats_extra)) {
int r; int r;
int db_index = myrandom_r(arg->random_data)%arg->num_DBs; int db_index = myrandom_r(arg->random_data)%arg->cli->num_DBs;
DB* db = arg->dbp[db_index]; DB* db = arg->dbp[db_index];
int curr_val_sum = 0; int curr_val_sum = 0;
DBT key, val; DBT key, val;
...@@ -834,10 +826,10 @@ static int UU()update_op(DB_TXN *txn, ARG arg, void* operation_extra, void *UU(s ...@@ -834,10 +826,10 @@ static int UU()update_op(DB_TXN *txn, ARG arg, void* operation_extra, void *UU(s
extra.pad_bytes = 100; extra.pad_bytes = 100;
} }
} }
for (u_int32_t i = 0; i < arg->txn_size; i++) { for (u_int32_t i = 0; i < arg->cli->txn_size; i++) {
rand_key = myrandom_r(arg->random_data); rand_key = myrandom_r(arg->random_data);
if (arg->bounded_element_range) { if (arg->bounded_element_range) {
rand_key = rand_key % arg->num_elements; rand_key = rand_key % arg->cli->num_elements;
} }
extra.u.d.diff = myrandom_r(arg->random_data) % MAX_RANDOM_VAL; extra.u.d.diff = myrandom_r(arg->random_data) % MAX_RANDOM_VAL;
// just make every other value random // just make every other value random
...@@ -862,7 +854,7 @@ static int UU()update_op(DB_TXN *txn, ARG arg, void* operation_extra, void *UU(s ...@@ -862,7 +854,7 @@ static int UU()update_op(DB_TXN *txn, ARG arg, void* operation_extra, void *UU(s
extra.u.d.diff = -curr_val_sum; extra.u.d.diff = -curr_val_sum;
rand_key = myrandom_r(arg->random_data); rand_key = myrandom_r(arg->random_data);
if (arg->bounded_element_range) { if (arg->bounded_element_range) {
rand_key = rand_key % arg->num_elements; rand_key = rand_key % arg->cli->num_elements;
} }
r = db->update( r = db->update(
db, db,
...@@ -883,7 +875,7 @@ static int UU() update_with_history_op(DB_TXN *txn, ARG arg, void* operation_ext ...@@ -883,7 +875,7 @@ static int UU() update_with_history_op(DB_TXN *txn, ARG arg, void* operation_ext
assert(arg->bounded_element_range); assert(arg->bounded_element_range);
assert(op_args->update_history_buffer); assert(op_args->update_history_buffer);
int r; int r;
int db_index = myrandom_r(arg->random_data)%arg->num_DBs; int db_index = myrandom_r(arg->random_data)%arg->cli->num_DBs;
DB* db = arg->dbp[db_index]; DB* db = arg->dbp[db_index];
int curr_val_sum = 0; int curr_val_sum = 0;
DBT key, val; DBT key, val;
...@@ -898,8 +890,8 @@ static int UU() update_with_history_op(DB_TXN *txn, ARG arg, void* operation_ext ...@@ -898,8 +890,8 @@ static int UU() update_with_history_op(DB_TXN *txn, ARG arg, void* operation_ext
extra.pad_bytes = 500; extra.pad_bytes = 500;
} }
} }
for (u_int32_t i = 0; i < arg->txn_size; i++) { for (u_int32_t i = 0; i < arg->cli->txn_size; i++) {
rand_key = myrandom_r(arg->random_data) % arg->num_elements; rand_key = myrandom_r(arg->random_data) % arg->cli->num_elements;
extra.u.h.new = myrandom_r(arg->random_data) % MAX_RANDOM_VAL; extra.u.h.new = myrandom_r(arg->random_data) % MAX_RANDOM_VAL;
// just make every other value random // just make every other value random
if (i%2 == 0) { if (i%2 == 0) {
...@@ -925,7 +917,7 @@ static int UU() update_with_history_op(DB_TXN *txn, ARG arg, void* operation_ext ...@@ -925,7 +917,7 @@ static int UU() update_with_history_op(DB_TXN *txn, ARG arg, void* operation_ext
extra.u.h.new = -curr_val_sum; extra.u.h.new = -curr_val_sum;
rand_key = myrandom_r(arg->random_data); rand_key = myrandom_r(arg->random_data);
if (arg->bounded_element_range) { if (arg->bounded_element_range) {
rand_key = rand_key % arg->num_elements; rand_key = rand_key % arg->cli->num_elements;
} }
extra.u.h.expected = op_args->update_history_buffer[rand_key]; extra.u.h.expected = op_args->update_history_buffer[rand_key];
op_args->update_history_buffer[rand_key] = extra.u.h.new; op_args->update_history_buffer[rand_key] = extra.u.h.new;
...@@ -946,7 +938,7 @@ static int UU() update_with_history_op(DB_TXN *txn, ARG arg, void* operation_ext ...@@ -946,7 +938,7 @@ static int UU() update_with_history_op(DB_TXN *txn, ARG arg, void* operation_ext
static int UU() update_broadcast_op(DB_TXN *txn, ARG arg, void* UU(operation_extra), void *UU(stats_extra)) { static int UU() update_broadcast_op(DB_TXN *txn, ARG arg, void* UU(operation_extra), void *UU(stats_extra)) {
struct update_op_extra extra; struct update_op_extra extra;
ZERO_STRUCT(extra); ZERO_STRUCT(extra);
int db_index = myrandom_r(arg->random_data)%arg->num_DBs; int db_index = myrandom_r(arg->random_data)%arg->cli->num_DBs;
DB* db = arg->dbp[db_index]; DB* db = arg->dbp[db_index];
extra.type = UPDATE_NEGATE; extra.type = UPDATE_NEGATE;
extra.pad_bytes = 0; extra.pad_bytes = 0;
...@@ -958,7 +950,7 @@ static int UU() update_broadcast_op(DB_TXN *txn, ARG arg, void* UU(operation_ext ...@@ -958,7 +950,7 @@ static int UU() update_broadcast_op(DB_TXN *txn, ARG arg, void* UU(operation_ext
static int UU() hot_op(DB_TXN *UU(txn), ARG UU(arg), void* UU(operation_extra), void *UU(stats_extra)) { static int UU() hot_op(DB_TXN *UU(txn), ARG UU(arg), void* UU(operation_extra), void *UU(stats_extra)) {
int r; int r;
for (int i = 0; i < arg->num_DBs; i++) { for (int i = 0; i < arg->cli->num_DBs; i++) {
DB* db = arg->dbp[i]; DB* db = arg->dbp[i];
r = db->hot_optimize(db, NULL, NULL); r = db->hot_optimize(db, NULL, NULL);
CKERR(r); CKERR(r);
...@@ -968,7 +960,7 @@ static int UU() hot_op(DB_TXN *UU(txn), ARG UU(arg), void* UU(operation_extra), ...@@ -968,7 +960,7 @@ static int UU() hot_op(DB_TXN *UU(txn), ARG UU(arg), void* UU(operation_extra),
static int UU() remove_and_recreate_me(DB_TXN *UU(txn), ARG arg, void* UU(operation_extra), void *UU(stats_extra)) { static int UU() remove_and_recreate_me(DB_TXN *UU(txn), ARG arg, void* UU(operation_extra), void *UU(stats_extra)) {
int r; int r;
int db_index = myrandom_r(arg->random_data)%arg->num_DBs; int db_index = myrandom_r(arg->random_data)%arg->cli->num_DBs;
DB* db = arg->dbp[db_index]; DB* db = arg->dbp[db_index];
r = (db)->close(db, 0); CKERR(r); r = (db)->close(db, 0); CKERR(r);
...@@ -1284,7 +1276,7 @@ static struct cli_args UU() get_default_args(void) { ...@@ -1284,7 +1276,7 @@ static struct cli_args UU() get_default_args(void) {
.do_recover = false, .do_recover = false,
.num_update_threads = 1, .num_update_threads = 1,
.num_put_threads = 1, .num_put_threads = 1,
.crash_on_update_failure = true, .crash_on_operation_failure = true,
.print_performance = false, .print_performance = false,
.print_thread_performance = false, .print_thread_performance = false,
.performance_period = 1, .performance_period = 1,
...@@ -1337,7 +1329,7 @@ static inline void parse_stress_test_args (int argc, char *const argv[], struct ...@@ -1337,7 +1329,7 @@ static inline void parse_stress_test_args (int argc, char *const argv[], struct
fprintf(stderr, "\t--txn_size INT (default %d rows)\n", default_args.txn_size); fprintf(stderr, "\t--txn_size INT (default %d rows)\n", default_args.txn_size);
fprintf(stderr, "\t--key_size INT (default %d, minimum %ld)\n", default_args.key_size, MIN_KEY_SIZE); fprintf(stderr, "\t--key_size INT (default %d, minimum %ld)\n", default_args.key_size, MIN_KEY_SIZE);
fprintf(stderr, "\t--val_size INT (default %d, minimum %ld)\n", default_args.val_size, MIN_VAL_SIZE); fprintf(stderr, "\t--val_size INT (default %d, minimum %ld)\n", default_args.val_size, MIN_VAL_SIZE);
fprintf(stderr, "\t--[no-]crash_on_update_failure BOOL (default %s)\n", default_args.crash_on_update_failure ? "yes" : "no"); fprintf(stderr, "\t--[no-]crash_on_operation_failure BOOL (default %s)\n", default_args.crash_on_operation_failure ? "yes" : "no");
fprintf(stderr, "\t--single_txn BOOL (default %s)\n", default_args.single_txn ? "yes" : "no"); fprintf(stderr, "\t--single_txn BOOL (default %s)\n", default_args.single_txn ? "yes" : "no");
fprintf(stderr, "\t--warm_cache BOOL (default %s)\n", default_args.warm_cache ? "yes" : "no"); fprintf(stderr, "\t--warm_cache BOOL (default %s)\n", default_args.warm_cache ? "yes" : "no");
fprintf(stderr, "\t--print_performance \n"); fprintf(stderr, "\t--print_performance \n");
...@@ -1397,11 +1389,11 @@ static inline void parse_stress_test_args (int argc, char *const argv[], struct ...@@ -1397,11 +1389,11 @@ static inline void parse_stress_test_args (int argc, char *const argv[], struct
argc--; argv++; argc--; argv++;
args->num_put_threads = atoi(argv[1]); args->num_put_threads = atoi(argv[1]);
} }
else if (strcmp(argv[1], "--crash_on_update_failure") == 0 && argc > 1) { else if (strcmp(argv[1], "--crash_on_operation_failure") == 0 && argc > 1) {
args->crash_on_update_failure = true; args->crash_on_operation_failure = true;
} }
else if (strcmp(argv[1], "--no-crash_on_update_failure") == 0 && argc > 1) { else if (strcmp(argv[1], "--no-crash_on_operation_failure") == 0 && argc > 1) {
args->crash_on_update_failure = false; args->crash_on_operation_failure = false;
} }
else if (strcmp(argv[1], "--print_performance") == 0 && argc > 1) { else if (strcmp(argv[1], "--print_performance") == 0 && argc > 1) {
args->print_performance = true; args->print_performance = true;
...@@ -1487,7 +1479,7 @@ do_warm_cache(DB_ENV *env, DB **dbs, struct cli_args *args) ...@@ -1487,7 +1479,7 @@ do_warm_cache(DB_ENV *env, DB **dbs, struct cli_args *args)
soe.fwd = true; soe.fwd = true;
soe.prefetch = true; soe.prefetch = true;
struct arg scan_arg; struct arg scan_arg;
arg_init(&scan_arg, args->num_elements, dbs, env, args); arg_init(&scan_arg, dbs, env, args);
scan_arg.operation_extra = &soe; scan_arg.operation_extra = &soe;
scan_arg.operation = scan_op_no_check; scan_arg.operation = scan_op_no_check;
scan_arg.lock_type = STRESS_LOCK_NONE; scan_arg.lock_type = STRESS_LOCK_NONE;
...@@ -1542,7 +1534,7 @@ UU() stress_recover(struct cli_args *args) { ...@@ -1542,7 +1534,7 @@ UU() stress_recover(struct cli_args *args) {
DB_TXN* txn = NULL; DB_TXN* txn = NULL;
struct arg recover_args; struct arg recover_args;
arg_init(&recover_args, args->num_elements, dbs, env, args); arg_init(&recover_args, dbs, env, args);
int r = env->txn_begin(env, 0, &txn, recover_args.txn_type); int r = env->txn_begin(env, 0, &txn, recover_args.txn_type);
CKERR(r); CKERR(r);
struct scan_op_extra soe; struct scan_op_extra soe;
......
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