diff options
author | Susan LoVerso <sue@wiredtiger.com> | 2014-09-25 10:35:05 -0400 |
---|---|---|
committer | Susan LoVerso <sue@wiredtiger.com> | 2014-09-25 10:35:05 -0400 |
commit | 0db835e32567e5fdcc1c6a1e67b8d4269f2355c5 (patch) | |
tree | d81302f9d4405846552abbbdd15acfabed4e6232 /bench | |
parent | a001258831b7520010f79b35e79cd9e0b6e31e9d (diff) | |
download | mongo-0db835e32567e5fdcc1c6a1e67b8d4269f2355c5.tar.gz |
Minor cleanup of new wtperf throttle code.
Diffstat (limited to 'bench')
-rw-r--r-- | bench/wtperf/wtperf.c | 19 | ||||
-rw-r--r-- | bench/wtperf/wtperf.h | 6 |
2 files changed, 17 insertions, 8 deletions
diff --git a/bench/wtperf/wtperf.c b/bench/wtperf/wtperf.c index 418c17279e0..242211a6d97 100644 --- a/bench/wtperf/wtperf.c +++ b/bench/wtperf/wtperf.c @@ -620,11 +620,11 @@ op_err: lprintf(cfg, ret, 0, op = thread->workload->ops; /* - * Check throttling every 100 operations to avoid taking too + * Check throttling periodically to avoid taking too * many time samples. */ if (thread->workload->throttle != 0 && - throttle_ops++ % 100 == 0) + throttle_ops++ % THROTTLE_OPS == 0) worker_throttle(thread->workload->throttle, &throttle_ops, &interval); } @@ -1300,8 +1300,8 @@ execute_populate(CONFIG *cfg) msecs = ns_to_ms(WT_TIMEDIFF(stop, start)); lprintf(cfg, 0, 1, "Load time: %.2f\n" "load ops/sec: %" PRIu64, - (double)msecs / (double)THOUSAND, - (uint64_t)((cfg->icount / msecs) / THOUSAND)); + (double)msecs / (double)MSEC_PER_SEC, + (uint64_t)((cfg->icount / msecs) / MSEC_PER_SEC)); /* * If configured, compact to allow LSM merging to complete. We @@ -2233,11 +2233,14 @@ worker_throttle(int64_t throttle, int64_t *ops, struct timespec *interval) if (__wt_epoch(NULL, &now) != 0) return; - /* If more than a second has passed reset the counters */ -#define WTPERF_US_PER_SECOND 1000000 + /* + * If we've completed enough operations, reset the counters. + * If we did enough operations in less than a second, sleep for + * the rest of the second. + */ usecs_to_complete = ns_to_us(WT_TIMEDIFF(now, *interval)); - if (usecs_to_complete < WTPERF_US_PER_SECOND) - (void)usleep(WTPERF_US_PER_SECOND - usecs_to_complete); + if (usecs_to_complete < USEC_PER_SEC) + (void)usleep(USEC_PER_SEC - usecs_to_complete); *ops = 0; *interval = now; diff --git a/bench/wtperf/wtperf.h b/bench/wtperf/wtperf.h index 06f7c635d5d..94cc7ab1c2a 100644 --- a/bench/wtperf/wtperf.h +++ b/bench/wtperf/wtperf.h @@ -136,6 +136,8 @@ struct __config { /* Configuration struction */ #define ELEMENTS(a) (sizeof(a) / sizeof(a[0])) +#define THROTTLE_OPS 100 + /* From include/os.h */ #define WT_TIMEDIFF(end, begin) \ (1000000000 * (uint64_t)((end).tv_sec - (begin).tv_sec) + \ @@ -145,6 +147,10 @@ struct __config { /* Configuration struction */ #define MILLION (1000000ULL) #define BILLION (1000000000ULL) +#define NSEC_PER_SEC BILLION +#define USEC_PER_SEC MILLION +#define MSEC_PER_SEC THOUSAND + #define ns_to_ms(v) ((v) / MILLION) #define ns_to_sec(v) ((v) / BILLION) #define ns_to_us(v) ((v) / THOUSAND) |