From b5184d6e75b884f98c8aea37d1604f0a244b31cc Mon Sep 17 00:00:00 2001 From: Max Rijevski Date: Thu, 7 Apr 2016 13:11:20 -0700 Subject: performance/io-threads: Reduce the number of timing calls in iot_worker Summary: - Reduce the amount of unnecessary timing calls in iot_worker servicing. - The current logic is unnecessarily accurate and hurts performance for many small FOPS. Change-Id: I6db4f1ad9a48d9d474bb251a2204969061021954 BUG: 1522950 Signed-off-by: Shreyas Siravara Reviewed-on: http://review.gluster.org/16081 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Kevin Vigor --- libglusterfs/src/compat.h | 4 ++++ xlators/performance/io-threads/src/io-threads.c | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/libglusterfs/src/compat.h b/libglusterfs/src/compat.h index 0cf19b099f8..af192f3c73f 100644 --- a/libglusterfs/src/compat.h +++ b/libglusterfs/src/compat.h @@ -490,6 +490,10 @@ int gf_mkostemp (char *tmpl, int suffixlen, int flags); #define ST_CTIM_NSEC_SET(stbuf, val) do { } while (0); #endif +#ifdef GF_BSD_HOST_OS +#define CLOCK_REALTIME_COARSE CLOCK_REALTIME +#endif + #ifndef IPV6_DEFAULT #ifndef IXDR_GET_LONG diff --git a/xlators/performance/io-threads/src/io-threads.c b/xlators/performance/io-threads/src/io-threads.c index 7aafc8accf5..7fc153dddeb 100644 --- a/xlators/performance/io-threads/src/io-threads.c +++ b/xlators/performance/io-threads/src/io-threads.c @@ -174,8 +174,6 @@ iot_worker (void *data) THIS = this; for (;;) { - sleep_till.tv_sec = time (NULL) + conf->idle_time; - pthread_mutex_lock (&conf->mutex); { if (pri != -1) { @@ -188,8 +186,11 @@ iot_worker (void *data) break; } - conf->sleep_count++; + clock_gettime (CLOCK_REALTIME_COARSE, + &sleep_till); + sleep_till.tv_sec += conf->idle_time; + conf->sleep_count++; ret = pthread_cond_timedwait (&conf->cond, &conf->mutex, &sleep_till); -- cgit