Commit d20de9fd authored by John Esmet's avatar John Esmet Committed by Yoni Fogel

refs #5164 perf insert multiple does env->put_multiple


git-svn-id: file:///svn/toku/tokudb@45061 c7de825b-a66e-492c-adef-691d508d4ae1
parent 7e518771
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#ident "$Id: perf_insert.c 44885 2012-06-25 17:55:52Z leifwalsh $"
#include "test.h"
#include <stdio.h>
#include <stdlib.h>
#include <toku_pthread.h>
#include <unistd.h>
#include <memory.h>
#include <sys/stat.h>
#include <db.h>
#include "threaded_stress_test_helpers.h"
// The intent of this test is to measure the throughput of db->puts
// with multiple threads.
static void
stress_table(DB_ENV* env, DB** dbp, struct cli_args *cli_args) {
if (verbose) printf("starting creation of pthreads\n");
const int num_threads = cli_args->num_put_threads;
struct arg myargs[num_threads];
operation_t put_op = random_put_multiple_op;
struct serial_put_extra spe[num_threads];
ZERO_ARRAY(spe);
for (int i = 0; i < num_threads; i++) {
arg_init(&myargs[i], dbp, env, cli_args);
myargs[i].operation = put_op;
if (cli_args->serial_insert) {
myargs[i].operation_extra = &spe[i];
}
}
run_workers(myargs, num_threads, cli_args->time_of_test, false, cli_args);
}
int
test_main(int argc, char *const argv[]) {
struct cli_args args = get_default_args_for_perf();
args.num_elements = 0; // want to start with empty DBs
parse_stress_test_args(argc, argv, &args);
stress_test_main_with_cmp(&args, stress_uint64_dbt_cmp);
return 0;
}
......@@ -759,6 +759,65 @@ cleanup:
return r;
}
static int UU() random_put_multiple_op(DB_TXN *txn, ARG arg, void *UU(operation_extra), void *stats_extra) {
const int num_dbs = arg->cli->num_DBs;
DB **dbs = arg->dbp;
DB_ENV *env = arg->env;
DBT mult_key_dbt[num_dbs];
DBT mult_put_dbt[num_dbs];
uint32_t mult_put_flags[num_dbs];
memset(mult_key_dbt, 0, sizeof(mult_key_dbt));
memset(mult_put_dbt, 0, sizeof(mult_put_dbt));
memset(mult_put_flags, 0, sizeof(mult_put_dbt));
int r = 0;
uint8_t rand_key_b[size_t_max(arg->cli->key_size, sizeof(uint64_t))];
uint64_t *rand_key_key = (void *) rand_key_b;
uint16_t *rand_key_i = (void *) rand_key_b;
ZERO_ARRAY(rand_key_b);
uint8_t valbuf[arg->cli->val_size];
ZERO_ARRAY(valbuf);
uint64_t puts_to_increment = 0;
for (uint32_t i = 0; i < arg->cli->txn_size; ++i) {
rand_key_key[0] = randu64(arg->random_data);
if (arg->cli->interleave) {
rand_key_i[3] = arg->thread_idx;
} else {
rand_key_i[0] = arg->thread_idx;
}
fill_zeroed_array(valbuf, arg->cli->val_size, arg->random_data, arg->cli->compressibility);
DBT key, val;
dbt_init(&key, &rand_key_b, sizeof rand_key_b);
dbt_init(&val, valbuf, sizeof valbuf);
r = env->put_multiple(
env,
dbs[0], // source db. this is arbitrary.
txn,
&key, // source db key
&val, // source db value
num_dbs, // total number of dbs
dbs, // array of dbs
mult_key_dbt, // array of keys
mult_put_dbt, // array of values
mult_put_flags // array of flags
);
if (r != 0) {
goto cleanup;
}
puts_to_increment++;
if (puts_to_increment == 100) {
increment_counter(stats_extra, PUTS, puts_to_increment);
puts_to_increment = 0;
}
}
cleanup:
return r;
}
struct leaf_entry * le;
const struct leaf_entry * le;
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->cli->num_DBs;
DB* db = arg->dbp[db_index];
......
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