summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDon Anderson <dda@ddanderson.com>2013-08-01 14:50:28 -0400
committerDon Anderson <dda@ddanderson.com>2013-08-01 14:50:28 -0400
commitc2e4f5ec3b7c172b601b737367197f1bc4a9ba4a (patch)
treeacf996bdf2b3268262f13e8436ffd6ba6ccc5b7b
parent5c044b68ed4239fd4998fa8ee8ee37b8b471307c (diff)
downloadmongo-c2e4f5ec3b7c172b601b737367197f1bc4a9ba4a.tar.gz
Added a help description to the definition of each option.
Added config_opt_usage() that prints all options/default values/descriptions. Removed command line options that are available via -o/-O. refs #593
-rw-r--r--bench/wtperf/wtperf.c160
-rw-r--r--bench/wtperf/wtperf_opt.i96
2 files changed, 116 insertions, 140 deletions
diff --git a/bench/wtperf/wtperf.c b/bench/wtperf/wtperf.c
index ebe0f4fa144..b50debb6541 100644
--- a/bench/wtperf/wtperf.c
+++ b/bench/wtperf/wtperf.c
@@ -85,6 +85,8 @@ typedef enum {
typedef struct {
const char *name;
+ const char *description;
+ const char *defaultval;
CONFIG_OPT_TYPE type;
size_t offset;
uint32_t flagmask;
@@ -119,6 +121,7 @@ int config_opt_str(CONFIG *, WT_SESSION *, const char *, const char *);
int config_opt_int(CONFIG *, WT_SESSION *, const char *, const char *);
int config_opt_file(CONFIG *, WT_SESSION *, const char *);
int config_opt_line(CONFIG *, WT_SESSION *, const char *);
+void config_opt_usage(void);
void *populate_thread(void *);
void print_config(CONFIG *);
void *read_thread(void *);
@@ -817,7 +820,7 @@ int main(int argc, char **argv)
WT_CONNECTION *conn;
WT_SESSION *parse_session;
const char *user_cconfig, *user_tconfig;
- const char *opts = "C:I:O:P:R:U:T:c:d:eh:i:jk:l:m:o:r:ps:t:u:v:SML";
+ const char *opts = "C:O:T:h:o:v:SML";
char *cc_buf, *tc_buf;
int ch, checkpoint_created, ret, stat_created;
pthread_t checkpoint, stat;
@@ -891,7 +894,7 @@ int main(int argc, char **argv)
return (EINVAL);
break;
default:
- /* Validation is provided on the next parse. */
+ /* Validation done previously. */
break;
}
@@ -899,101 +902,22 @@ int main(int argc, char **argv)
optind = 1;
while ((ch = getopt(argc, argv, opts)) != EOF)
switch (ch) {
- case 'd':
- config_opt_int(&cfg, parse_session, "data_sz", optarg);
- break;
- case 'c':
- config_opt_int(&cfg, parse_session,
- "checkpoint_interval", optarg);
- break;
- case 'e':
- cfg.create = 0;
- break;
- case 'h':
- /* handled above */
- break;
- case 'i':
- config_opt_int(&cfg, parse_session, "icount", optarg);
- break;
- case 'j':
- F_SET(&cfg, PERF_INSERT_RMW);
- break;
- case 'k':
- config_opt_int(&cfg, parse_session, "key_sz", optarg);
- break;
- case 'l':
- config_opt_int(&cfg, parse_session,
- "stat_interval", optarg);
- break;
- case 'm':
- F_SET(&cfg, PERF_RAND_WORKLOAD);
- config_opt_int(&cfg, parse_session,
- "rand_range", optarg);
- if (cfg.rand_range == 0) {
- fprintf(stderr, "Invalid random range.\n");
- usage();
- return (EINVAL);
- }
-
- break;
case 'o':
/* Allow -o key=value */
if (config_opt_line(&cfg,
parse_session, optarg) != 0)
return (EINVAL);
break;
- case 'p':
- F_SET(&cfg, PERF_RAND_PARETO);
- break;
- case 'r':
- config_opt_int(&cfg, parse_session, "run_time", optarg);
- break;
- case 's':
- config_opt_int(&cfg, parse_session,
- "rand_seed", optarg);
- break;
- case 't':
- config_opt_int(&cfg, parse_session,
- "report_interval", optarg);
- break;
- case 'u':
- config_opt_str(&cfg, parse_session, "uri", optarg);
- break;
case 'v':
config_opt_int(&cfg, parse_session, "verbose", optarg);
break;
case 'C':
user_cconfig = optarg;
break;
- case 'I':
- config_opt_int(&cfg, parse_session,
- "insert_threads", optarg);
- break;
- case 'P':
- config_opt_int(&cfg, parse_session,
- "populate_threads", optarg);
- break;
- case 'R':
- config_opt_int(&cfg, parse_session,
- "read_threads", optarg);
- break;
- case 'U':
- config_opt_int(&cfg, parse_session,
- "update_threads", optarg);
- break;
case 'T':
user_tconfig = optarg;
break;
- case 'O':
- case 'L':
- case 'M':
- case 'S':
break;
- case '?':
- default:
- fprintf(stderr, "Invalid option\n");
- usage();
- return (EINVAL);
}
if (cfg.rand_range > 0 && !F_ISSET(&cfg, PERF_RAND_WORKLOAD)) {
@@ -1001,6 +925,11 @@ int main(int argc, char **argv)
"random workload\n");
return (EINVAL);
}
+ if (cfg.rand_range == 0 && F_ISSET(&cfg, PERF_RAND_WORKLOAD)) {
+ fprintf(stderr, "Invalid random range.\n");
+ usage();
+ return (EINVAL);
+ }
if ((ret = setup_log_file(&cfg)) != 0)
goto err;
@@ -1427,6 +1356,45 @@ config_opt_int(CONFIG *cfg, WT_SESSION *parse_session,
return (ret);
}
+void
+config_opt_usage(void)
+{
+ int i;
+ size_t nopt;
+ const char *typestr;
+ const char *defaultval;
+ int linelen;
+
+ printf("Following are options setable using -o or -O, "
+ "showing [default value].\n");
+ printf("String values must be enclosed by \" quotes,\n");
+ printf("bool values must be true or false.\n\n");
+
+ nopt = sizeof(config_opts)/sizeof(config_opts[0]);
+ for (i = 0; i < nopt; i++) {
+ typestr = "?";
+ defaultval = config_opts[i].defaultval;
+ if (config_opts[i].type == UINT32_TYPE)
+ typestr = "int";
+ else if (config_opts[i].type == STRING_TYPE)
+ typestr = "string";
+ else if (config_opts[i].type == BOOL_TYPE ||
+ config_opts[i].type == FLAG_TYPE) {
+ typestr = "bool";
+ if (strcmp(defaultval, "0") == 0)
+ defaultval = "true";
+ else
+ defaultval = "false";
+ }
+ linelen = printf(" %s=<%s> [%s]",
+ config_opts[i].name, typestr, defaultval);
+ if (linelen + 2 + strlen(config_opts[i].description) < 80)
+ printf(" %s\n", config_opts[i].description);
+ else
+ printf("\n %s\n", config_opts[i].description);
+ }
+}
+
int
start_threads(
CONFIG *cfg, u_int num, pthread_t **threadsp, void *(*func)(void *))
@@ -1606,32 +1574,18 @@ void print_config(CONFIG *cfg)
void usage(void)
{
- printf("wtperf [-CLMPRSTdehikrsuv]\n");
+ printf("wtperf [-CLMOSThov]\n");
printf("\t-S Use a small default configuration\n");
printf("\t-M Use a medium default configuration\n");
printf("\t-L Use a large default configuration\n");
+ printf("\t-h <string> Wired Tiger home must exist, default WT_TEST\n");
printf("\t-C <string> additional connection configuration\n");
- printf("\t-I <int> number of insert worker threads\n");
- printf("\t-P <int> number of populate threads\n");
- printf("\t-R <int> number of read threads\n");
- printf("\t-U <int> number of update threads\n");
+ printf("\t (added to option conn_config)\n");
printf("\t-T <string> additional table configuration\n");
- printf("\t-c <int> checkpoint every <int> report intervals."
- "Default disabled,\n");
- printf("\t-d <int> data item size\n");
- printf("\t-e use existing database (skip population phase)\n");
- printf("\t-h <string> Wired Tiger home must exist, default WT_TEST \n");
- printf("\t-i <int> number of records to insert\n");
- printf("\t-j Execute a read prior to each insert in populate\n");
- printf("\t-k <int> key item size\n");
- printf("\t-l <int> log statistics every <int> report intervals."
- "Default disabled.\n");
- printf("\t-m <range> use random inserts in workload. Means reads"
- " and updates will ignore WT_NOTFOUND\n");
- printf("\t-p use pareto 80/20 distribution for random numbers\n");
- printf("\t-r <int> number of seconds to run workload phase\n");
- printf("\t-s <int> seed for random number generator\n");
- printf("\t-t <int> How often to output throughput information\n");
- printf("\t-u <string> table uri, default lsm:test\n");
+ printf("\t (added to option table_config)\n");
printf("\t-v <int> verbosity\n");
+ printf("\t-O <filename> file contains options as listed below\n");
+ printf("\t-o option=val[,option=val,...] set options listed below\n");
+ printf("\n");
+ config_opt_usage();
}
diff --git a/bench/wtperf/wtperf_opt.i b/bench/wtperf/wtperf_opt.i
index bd58f16234b..c17e16eee2a 100644
--- a/bench/wtperf/wtperf_opt.i
+++ b/bench/wtperf/wtperf_opt.i
@@ -29,57 +29,79 @@
*/
#ifdef OPT_DECLARE_STRUCT
-#define DEF_OPT_AS_STRING(name, initval) const char *name;
-#define DEF_OPT_AS_BOOL(name, initval) uint32_t name;
-#define DEF_OPT_AS_UINT32(name, initval) uint32_t name;
-#define DEF_OPT_AS_FLAGVAL(name, bits)
+#define DEF_OPT_AS_STRING(name, initval, desc) const char *name;
+#define DEF_OPT_AS_BOOL(name, initval, desc) uint32_t name;
+#define DEF_OPT_AS_UINT32(name, initval, desc) uint32_t name;
+#define DEF_OPT_AS_FLAGVAL(name, bits, desc)
#endif
#ifdef OPT_DEFINE_DESC
-#define DEF_OPT_AS_STRING(name, initval) \
- { #name, STRING_TYPE, offsetof(CONFIG, name), 0 },
-#define DEF_OPT_AS_BOOL(name, initval) \
- { #name, BOOL_TYPE, offsetof(CONFIG, name), 0 },
-#define DEF_OPT_AS_UINT32(name, initval) \
- { #name, UINT32_TYPE, offsetof(CONFIG, name), 0 },
-#define DEF_OPT_AS_FLAGVAL(name, bits) \
- { #name, FLAG_TYPE, offsetof(CONFIG, flags), bits },
+#define DEF_OPT_AS_STRING(name, initval, desc) \
+ { #name, desc, #initval, STRING_TYPE, offsetof(CONFIG, name), 0 },
+#define DEF_OPT_AS_BOOL(name, initval, desc) \
+ { #name, desc, #initval, BOOL_TYPE, offsetof(CONFIG, name), 0 },
+#define DEF_OPT_AS_UINT32(name, initval, desc) \
+ { #name, desc, #initval, UINT32_TYPE, offsetof(CONFIG, name), 0 },
+#define DEF_OPT_AS_FLAGVAL(name, bits, desc) \
+ { #name, desc, "0", FLAG_TYPE, offsetof(CONFIG, flags), bits },
#endif
#ifdef OPT_DEFINE_DEFAULT
-#define DEF_OPT_AS_STRING(name, initval) initval,
-#define DEF_OPT_AS_BOOL(name, initval) initval,
-#define DEF_OPT_AS_UINT32(name, initval) initval,
-#define DEF_OPT_AS_FLAGVAL(name, bits)
+#define DEF_OPT_AS_STRING(name, initval, desc) initval,
+#define DEF_OPT_AS_BOOL(name, initval, desc) initval,
+#define DEF_OPT_AS_UINT32(name, initval, desc) initval,
+#define DEF_OPT_AS_FLAGVAL(name, bits, desc)
#endif
/*
* CONFIG struct fields that may be altered on command line via -o and -O.
* The default values are tiny, we want the basic run to be fast.
*/
-DEF_OPT_AS_UINT32(checkpoint_interval, 0) /* Zero to disable. */
-DEF_OPT_AS_STRING(conn_config, "create,cache_size=200MB")
-DEF_OPT_AS_BOOL(create, 1) /* Whether to populate for this run. */
-DEF_OPT_AS_UINT32(data_sz, 100)
-DEF_OPT_AS_UINT32(icount, 5000) /* Items to insert. */
-DEF_OPT_AS_UINT32(insert_threads, 0) /* Number of insert threads. */
-DEF_OPT_AS_UINT32(key_sz, 20)
-DEF_OPT_AS_UINT32(populate_threads, 1) /* Number of populate threads. */
-DEF_OPT_AS_UINT32(rand_seed, 14023954)
-DEF_OPT_AS_UINT32(random_range, 0)
-DEF_OPT_AS_UINT32(read_threads, 2) /* Number of read threads. */
-DEF_OPT_AS_UINT32(report_interval, 2)
-DEF_OPT_AS_UINT32(run_time, 2)
-DEF_OPT_AS_UINT32(stat_interval, 0) /* Zero to disable. */
-DEF_OPT_AS_STRING(table_config, DEFAULT_LSM_CONFIG)
-DEF_OPT_AS_UINT32(update_threads, 0) /* Number of update threads. */
-DEF_OPT_AS_STRING(uri, "lsm:test")
-DEF_OPT_AS_UINT32(verbose, 0)
+DEF_OPT_AS_UINT32(checkpoint_interval, 0,
+ "checkpoint every <int> report intervals, zero to disable")
+DEF_OPT_AS_STRING(conn_config, "create,cache_size=200MB",
+ "connection configuration string")
+DEF_OPT_AS_BOOL(create, 1,
+ "do population phase; set to false to use existing database")
+DEF_OPT_AS_UINT32(data_sz, 100,
+ "data item size")
+DEF_OPT_AS_UINT32(icount, 5000,
+ "number of records to insert")
+DEF_OPT_AS_UINT32(insert_threads, 0,
+ "number of insert worker threads")
+DEF_OPT_AS_UINT32(key_sz, 20,
+ "key item size")
+DEF_OPT_AS_UINT32(populate_threads, 1,
+ "number of populate threads")
+DEF_OPT_AS_UINT32(rand_seed, 14023954,
+ "seed for random number generator")
+DEF_OPT_AS_UINT32(random_range, 0,
+ "use random inserts in workload, reads"
+ " and updates ignore WT_NOTFOUND")
+DEF_OPT_AS_UINT32(read_threads, 2,
+ "number of read threads")
+DEF_OPT_AS_UINT32(report_interval, 2,
+ "how often to output throughput information")
+DEF_OPT_AS_UINT32(run_time, 2,
+ "number of seconds to run workload phase")
+DEF_OPT_AS_UINT32(stat_interval, 0,
+ "log statistics every <int> report intervals, zero to disable")
+DEF_OPT_AS_STRING(table_config, DEFAULT_LSM_CONFIG,
+ "table configuration string")
+DEF_OPT_AS_UINT32(update_threads, 0,
+ "number of update threads")
+DEF_OPT_AS_STRING(uri,
+ "lsm:test", "table uri")
+DEF_OPT_AS_UINT32(verbose, 0,
+ "verbosity")
/* values for CONFIG.flags */
-DEF_OPT_AS_FLAGVAL(insert_rmw, PERF_INSERT_RMW)
-DEF_OPT_AS_FLAGVAL(pareto, PERF_RAND_PARETO)
-DEF_OPT_AS_FLAGVAL(random, PERF_RAND_WORKLOAD)
+DEF_OPT_AS_FLAGVAL(insert_rmw, PERF_INSERT_RMW,
+ "execute a read prior to each insert in populate")
+DEF_OPT_AS_FLAGVAL(pareto, PERF_RAND_PARETO,
+ "use pareto 80/20 distribution for random numbers")
+DEF_OPT_AS_FLAGVAL(random, PERF_RAND_WORKLOAD,
+ "use random workload as specified with random_range")
#undef DEF_OPT_AS_STRING
#undef DEF_OPT_AS_BOOL