From 85266149f824e7ffc74d73367af43fcc86242f4f Mon Sep 17 00:00:00 2001 From: Alex Gorrod Date: Wed, 22 Oct 2014 11:03:20 +1100 Subject: Add the code changes tfor wtperf ops_per_txn. --- bench/wtperf/config.c | 5 +++++ bench/wtperf/wtperf.c | 26 +++++++++++++++++++++++++- bench/wtperf/wtperf.h | 2 ++ bench/wtperf/wtperf_opt.i | 7 ++++++- 4 files changed, 38 insertions(+), 2 deletions(-) (limited to 'bench') diff --git a/bench/wtperf/config.c b/bench/wtperf/config.c index 3941a1b3d33..31b20621eea 100644 --- a/bench/wtperf/config.c +++ b/bench/wtperf/config.c @@ -224,6 +224,11 @@ config_threads(CONFIG *cfg, const char *config, size_t len) goto err; continue; } + if (STRING_MATCH("ops_per_txn", k.str, k.len)) { + if ((workp->ops_per_txn = v.val) < 0) + goto err; + continue; + } if (STRING_MATCH("read", k.str, k.len) || STRING_MATCH("reads", k.str, k.len)) { if ((workp->read = v.val) < 0) diff --git a/bench/wtperf/wtperf.c b/bench/wtperf/wtperf.c index 3d04da78aa5..b8776497a17 100644 --- a/bench/wtperf/wtperf.c +++ b/bench/wtperf/wtperf.c @@ -381,7 +381,7 @@ worker(void *arg) WT_CONNECTION *conn; WT_CURSOR **cursors, *cursor; WT_SESSION *session; - int64_t throttle_ops; + int64_t ops, ops_per_txn, throttle_ops; size_t i; uint64_t next_val, usecs; uint8_t *op, *op_end; @@ -395,6 +395,8 @@ worker(void *arg) session = NULL; trk = NULL; throttle_ops = 0; + ops = 0; + ops_per_txn = thread->workload->ops_per_txn; if ((ret = conn->open_session( conn, NULL, cfg->sess_config, &session)) != 0) { @@ -429,6 +431,12 @@ worker(void *arg) op = thread->workload->ops; op_end = op + sizeof(thread->workload->ops); + if (ops_per_txn != 0 && + (ret = session->begin_transaction(session, NULL)) != 0) { + lprintf(cfg, ret, 0, "First transaction begin failed"); + goto err; + } + while (!cfg->stop) { /* * Generate the next key and setup operation specific @@ -589,6 +597,22 @@ op_err: lprintf(cfg, ret, 0, ++trk->ops; } + /* Commit our work if configured for explicit transactions */ + if (ops_per_txn != 0 && ops++ % ops_per_txn == 0) { + if ((ret = session->commit_transaction( + session, NULL)) != 0) { + lprintf(cfg, ret, 0, + "Worker transaction commit failed"); + goto err; + } + if ((ret = session->begin_transaction( + session, NULL)) != 0) { + lprintf(cfg, ret, 0, + "Worker transaction commit failed"); + goto err; + } + } + /* Schedule the next operation */ if (++op == op_end) op = thread->workload->ops; diff --git a/bench/wtperf/wtperf.h b/bench/wtperf/wtperf.h index dfd11b24955..cc70e76bd5d 100644 --- a/bench/wtperf/wtperf.h +++ b/bench/wtperf/wtperf.h @@ -84,6 +84,8 @@ typedef struct { int64_t read; /* Read ratio */ int64_t update; /* Update ratio */ int64_t throttle; /* Maximum operations/second */ + /* Number of operations per transaction. Zero for autocommit */ + int64_t ops_per_txn; #define WORKER_INSERT 1 /* Insert */ #define WORKER_INSERT_RMW 2 /* Insert with read-modify-write */ diff --git a/bench/wtperf/wtperf_opt.i b/bench/wtperf/wtperf_opt.i index 606297eb438..c04f0f214f6 100644 --- a/bench/wtperf/wtperf_opt.i +++ b/bench/wtperf/wtperf_opt.i @@ -136,6 +136,10 @@ DEF_OPT_AS_UINT32(sample_interval, 0, DEF_OPT_AS_UINT32(sample_rate, 50, "how often the latency of operations is measured. One for every operation," "two for every second operation, three for every third operation etc.") +DEF_OPT_AS_STRING(schema_threads, "", "Sometimes it's interesting to have " + "tables being created and removed in parallel with other operations. " + "Valid options for the schema_workload setting are: create, populate, " + "rollback") DEF_OPT_AS_CONFIG_STRING(sess_config, "", "session configuration string") DEF_OPT_AS_CONFIG_STRING(table_config, "key_format=S,value_format=S,type=lsm,exclusive=true," @@ -155,7 +159,8 @@ DEF_OPT_AS_STRING(threads, "", "workload configuration: each 'count' " "'threads=((count=2,reads=1)(count=8,reads=1,inserts=2,updates=1))' " "which would create 2 threads doing nothing but reads and 8 threads " "each doing 50% inserts and 25% reads and updates. Allowed configuration " - "values are 'count', 'throttle', 'reads', 'inserts', 'updates'") + "values are 'count', 'throttle', 'reads', 'inserts', 'updates'. There are " + "also behavior modifiers, supported modifiers are 'ops_per_txn'") DEF_OPT_AS_CONFIG_STRING(transaction_config, "", "transaction configuration string, relevant when populate_opts_per_txn " "is nonzero") -- cgit v1.2.1