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 ...@@ -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) { static int perf_write(DB_TXN *txn, ARG arg, void* operation_extra, void *stats_extra) {
int db_index = *(int *)operation_extra; int db_index = *(int *)operation_extra;
DB* db = arg->dbp[db_index]; DB* db = arg->dbp[db_index];
int val_size = arg->cli->val_size; return random_put_in_db(db, txn, arg, true, stats_extra);
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;
} }
......
...@@ -709,7 +709,7 @@ size_t_max(size_t a, size_t b) { ...@@ -709,7 +709,7 @@ size_t_max(size_t a, size_t b) {
return (a > b) ? a : 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; int r = 0;
uint8_t rand_key_b[size_t_max(arg->cli->key_size, sizeof(uint64_t))]; 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; 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) { ...@@ -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); dbt_init(&val, valbuf, sizeof valbuf);
int flags = get_put_flags(arg->cli); int flags = get_put_flags(arg->cli);
r = db->put(db, txn, &key, &val, flags); r = db->put(db, txn, &key, &val, flags);
if (r != 0) { if (!ignore_errors && r != 0) {
goto cleanup; goto cleanup;
} }
puts_to_increment++; puts_to_increment++;
...@@ -805,13 +805,13 @@ cleanup: ...@@ -805,13 +805,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->cli->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, false, 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->cli->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, false, stats_extra);
} }
struct serial_put_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