Commit b26ea7f3 authored by Leif Walsh's avatar Leif Walsh Committed by Yoni Fogel

refs #5418 #5178 improvements to perf_read_write in preparation for testing


git-svn-id: file:///svn/toku/tokudb@49044 c7de825b-a66e-492c-adef-691d508d4ae1
parent f176676e
......@@ -29,25 +29,7 @@ static int perf_read(DB_TXN *txn, ARG arg, void* operation_extra, void *stats_ex
static int perf_write(DB_TXN *txn, ARG arg, void* operation_extra, void *stats_extra) {
int db_index = *(int *)operation_extra;
DB* db = arg->dbp[db_index];
int val_size = arg->cli->val_size;
char data[val_size];
memset(data, 0, sizeof(data));
for (uint32_t i = 0; i < arg->cli->txn_size; i++) {
// do a random insertion
int rand_key = random() % arg->cli->num_elements;
DBT key, val;
// do not care about errors
db->put(
db,
txn,
dbt_init(&key, &rand_key, sizeof(rand_key)),
dbt_init(&val, data, sizeof(data)),
0);
increment_counter(stats_extra, PUTS, 1);
}
return 0;
return random_put_in_db(db, txn, arg, true, stats_extra);
}
......
......@@ -709,7 +709,7 @@ size_t_max(size_t a, size_t b) {
return (a > b) ? a : b;
}
static int random_put_in_db(DB *db, DB_TXN *txn, ARG arg, void *stats_extra) {
static int random_put_in_db(DB *db, DB_TXN *txn, ARG arg, bool ignore_errors, void *stats_extra) {
int r = 0;
uint8_t rand_key_b[size_t_max(arg->cli->key_size, sizeof(uint64_t))];
uint64_t *rand_key_key = cast_to_typeof(rand_key_key) rand_key_b;
......@@ -732,7 +732,7 @@ static int random_put_in_db(DB *db, DB_TXN *txn, ARG arg, void *stats_extra) {
dbt_init(&val, valbuf, sizeof valbuf);
int flags = get_put_flags(arg->cli);
r = db->put(db, txn, &key, &val, flags);
if (r != 0) {
if (!ignore_errors && r != 0) {
goto cleanup;
}
puts_to_increment++;
......@@ -805,13 +805,13 @@ static int UU() random_put_multiple_op(DB_TXN *txn, ARG arg, void *UU(operation_
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];
return random_put_in_db(db, txn, arg, stats_extra);
return random_put_in_db(db, txn, arg, false, 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->cli->num_DBs;
DB* db = arg->dbp[db_index];
return random_put_in_db(db, txn, arg, stats_extra);
return random_put_in_db(db, txn, arg, false, stats_extra);
}
struct serial_put_extra {
......
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