path: root/
diff options
authorHarshavardhana <>2013-10-10 04:19:16 -0700
committerAnand Avati <>2013-10-15 00:14:57 -0700
commit6836118b214bb45ff94ae1bc176a6eefb1a17a6a (patch)
treeb600fc4deaab0c62c37241c6deef6f604d0088f1 /
parent793f8491789e58791b090a74472959df117e404b (diff)
libglusterfs: Add monotonic clocking counter for timer thread
gettimeofday() returns the current wall clock time and timezone. Using these functions in order to measure the passage of time (how long an operation took) therefore seems like a no-brainer. This time suffer's from some limitations: a. They have a low resolution: “High-performance” timing by definition, requires clock resolutions into the microseconds or better. b. They can jump forwards and backwards in time: Computer clocks all tick at slightly different rates, which causes the time to drift. Most systems have NTP enabled which periodically adjusts the system clock to keep them in sync with “actual” time. The adjustment can cause the clock to suddenly jump forward (artificially inflating your timing numbers) or jump backwards (causing your timing calculations to go negative or hugely positive). In such cases timer thread could go into an infinite loop. From 'man gettimeofday': ---------- .. .. The time returned by gettimeofday() is affected by discontinuous jumps in the system time (e.g., if the system administrator manually changes the system time). If you need a monotonically increasing clock, see clock_gettime(2). .. .. ---------- Rationale: For calculating interval timing for Timer thread, all that’s needed should be clock as a simple counter that increments at a stable rate. This is necessary to avoid the jumps which are caused by using "wall time", this counter must be monotonic that can never “tick” backwards, ever. Change-Id: I701d31e71a85a73d21a6c5cd15583e7a5a645eeb BUG: 1017993 Signed-off-by: Harshavardhana <> Reviewed-on: Tested-by: Gluster Build System <> Reviewed-by: Anand Avati <>
Diffstat (limited to '')
1 files changed, 4 insertions, 1 deletions
diff --git a/ b/
index 2ea5937ad..b8cb855a0 100644
--- a/
+++ b/
@@ -569,9 +569,13 @@ if test "x${have_linkat}" = "xyes"; then
+dnl check for Monotonic clock
+AC_CHECK_FUNC([clock_gettime], [has_monotonic_clock=yes], AC_CHECK_LIB([rt], [clock_gettime], , AC_MSG_WARN([System doesn't have monotonic clock using contrib])))
dnl Check for argp
AC_CHECK_HEADER([argp.h], AC_DEFINE(HAVE_ARGP, 1, [have argp]))
if test "x${ac_cv_header_argp_h}" = "xno"; then
@@ -653,7 +657,6 @@ fi
case $host_os in