diff options
Diffstat (limited to 'bench/wtperf/wtperf.h')
-rw-r--r-- | bench/wtperf/wtperf.h | 132 |
1 files changed, 123 insertions, 9 deletions
diff --git a/bench/wtperf/wtperf.h b/bench/wtperf/wtperf.h index e4b9fc00798..7dbe1822a26 100644 --- a/bench/wtperf/wtperf.h +++ b/bench/wtperf/wtperf.h @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -66,6 +66,7 @@ typedef struct __config CONFIG; typedef struct __config_thread CONFIG_THREAD; +typedef struct __truncate_queue_entry TRUNCATE_QUEUE_ENTRY; #define EXT_PFX ",extensions=(" #define EXT_SFX ")" @@ -90,7 +91,7 @@ typedef struct { int64_t insert; /* Insert ratio */ int64_t read; /* Read ratio */ int64_t update; /* Update ratio */ - int64_t throttle; /* Maximum operations/second */ + uint64_t throttle; /* Maximum operations/second */ /* Number of operations per transaction. Zero for autocommit */ int64_t ops_per_txn; int64_t truncate; /* Truncate ratio */ @@ -106,8 +107,7 @@ typedef struct { } WORKLOAD; /* Steering items for the truncate workload */ -typedef struct __truncate_struct TRUNCATE_CONFIG; -struct __truncate_struct { +typedef struct { uint64_t stone_gap; uint64_t needed_stones; uint64_t final_stone_gap; @@ -116,7 +116,8 @@ struct __truncate_struct { uint64_t last_total_inserts; uint64_t num_stones; uint64_t last_key; -}; + uint64_t catchup_multiplier; +} TRUNCATE_CONFIG; /* Queue entry for use with the Truncate Logic */ struct __truncate_queue_entry { @@ -124,7 +125,20 @@ struct __truncate_queue_entry { uint64_t diff; /* Number of items to be truncated*/ TAILQ_ENTRY(__truncate_queue_entry) q; }; -typedef struct __truncate_queue_entry TRUNCATE_QUEUE_ENTRY; + +struct __config_queue_entry { + char *string; + TAILQ_ENTRY(__config_queue_entry) c; +}; +typedef struct __config_queue_entry CONFIG_QUEUE_ENTRY; + +/* Steering for the throttle configuration */ +typedef struct { + struct timespec last_increment; /* Time that we last added more ops */ + uint64_t ops_count; /* The number of ops this increment */ + uint64_t ops_per_increment; /* Ops to add per increment */ + uint64_t usecs_increment; /* Time interval of each increment */ +} THROTTLE_CONFIG; #define LOG_PARTIAL_CONFIG ",log=(enabled=false)" /* @@ -173,6 +187,8 @@ struct __config { /* Configuration structure */ volatile int stop; /* notify threads to stop */ volatile int in_warmup; /* Running warmup phase */ + volatile bool idle_cycle_run; /* Signal for idle cycle thread */ + volatile uint32_t totalsec; /* total seconds running */ u_int has_truncate; /* if there is a truncate workload */ @@ -180,6 +196,9 @@ struct __config { /* Configuration structure */ /* Queue head for use with the Truncate Logic */ TAILQ_HEAD(__truncate_qh, __truncate_queue_entry) stone_head; + /* Queue head to save a copy of the config to be output */ + TAILQ_HEAD(__config_qh, __config_queue_entry) config_head; + /* Fields changeable on command line are listed in wtperf_opt.i */ #define OPT_DECLARE_STRUCT #include "wtperf_opt.i" @@ -188,6 +207,7 @@ struct __config { /* Configuration structure */ #define ELEMENTS(a) (sizeof(a) / sizeof(a[0])) +#define READ_RANGE_OPS 10 #define THROTTLE_OPS 100 #define THOUSAND (1000ULL) @@ -253,14 +273,16 @@ struct __config_thread { /* Per-thread structure */ WORKLOAD *workload; /* Workload */ + THROTTLE_CONFIG throttle_cfg; /* Throttle configuration */ + + TRUNCATE_CONFIG trunc_cfg; /* Truncate configuration */ + TRACK ckpt; /* Checkpoint operations */ TRACK insert; /* Insert operations */ TRACK read; /* Read operations */ TRACK update; /* Update operations */ TRACK truncate; /* Truncate operations */ TRACK truncate_sleep; /* Truncate sleep operations */ - TRUNCATE_CONFIG trunc_cfg; /* Truncate configuration */ - }; void cleanup_truncate_config(CONFIG *); @@ -270,17 +292,21 @@ void config_free(CONFIG *); int config_opt_file(CONFIG *, const char *); int config_opt_line(CONFIG *, const char *); int config_opt_str(CONFIG *, const char *, const char *); +void config_to_file(CONFIG *); +void config_consolidate(CONFIG *); void config_print(CONFIG *); int config_sanity(CONFIG *); void latency_insert(CONFIG *, uint32_t *, uint32_t *, uint32_t *); void latency_read(CONFIG *, uint32_t *, uint32_t *, uint32_t *); void latency_update(CONFIG *, uint32_t *, uint32_t *, uint32_t *); void latency_print(CONFIG *); -int enomem(const CONFIG *); int run_truncate( CONFIG *, CONFIG_THREAD *, WT_CURSOR *, WT_SESSION *, int *); int setup_log_file(CONFIG *); +int setup_throttle(CONFIG_THREAD*); int setup_truncate(CONFIG *, CONFIG_THREAD *, WT_SESSION *); +int start_idle_table_cycle(CONFIG *, pthread_t *); +int stop_idle_table_cycle(CONFIG *, pthread_t); uint64_t sum_ckpt_ops(CONFIG *); uint64_t sum_insert_ops(CONFIG *); uint64_t sum_pop_ops(CONFIG *); @@ -288,6 +314,7 @@ uint64_t sum_read_ops(CONFIG *); uint64_t sum_truncate_ops(CONFIG *); uint64_t sum_update_ops(CONFIG *); void usage(void); +int worker_throttle(CONFIG_THREAD*); void lprintf(const CONFIG *, int err, uint32_t, const char *, ...) #if defined(__GNUC__) @@ -304,4 +331,91 @@ generate_key(CONFIG *cfg, char *key_buf, uint64_t keyno) sprintf(key_buf, "%0*" PRIu64, cfg->key_sz - 1, keyno); } +static inline void +extract_key(char *key_buf, uint64_t *keynop) +{ + sscanf(key_buf, "%" SCNu64, keynop); +} + +/* + * die -- + * Print message and exit on failure. + */ +static inline void +die(int e, const char *str) +{ + fprintf(stderr, "Call to %s failed: %s", str, wiredtiger_strerror(e)); + exit(EXIT_FAILURE); +} + +/* + * dmalloc -- + * Call malloc, dying on failure. + */ +static inline void * +dmalloc(size_t len) +{ + void *p; + + if ((p = malloc(len)) == NULL) + die(errno, "malloc"); + return (p); +} + +/* + * dcalloc -- + * Call calloc, dying on failure. + */ +static inline void * +dcalloc(size_t num, size_t len) +{ + void *p; + + if ((p = calloc(len, num)) == NULL) + die(errno, "calloc"); + return (p); +} + +/* + * drealloc -- + * Call realloc, dying on failure. + */ +static inline void * +drealloc(void *p, size_t len) +{ + void *repl; + + if ((repl = realloc(p, len)) == NULL) + die(errno, "realloc"); + return (repl); +} + +/* + * dstrdup -- + * Call strdup, dying on failure. + */ +static inline char * +dstrdup(const char *str) +{ + char *p; + + if ((p = strdup(str)) == NULL) + die(errno, "strdup"); + return (p); +} + +/* + * dstrndup -- + * Call strndup, dying on failure. + */ +static inline char * +dstrndup(const char *str, const size_t len) +{ + char *p; + + if ((p = strndup(str, len)) == NULL) + die(errno, "strndup"); + return (p); +} + #endif |