From 6c80321aed4b620acba4ced1a7a5871377cbc396 Mon Sep 17 00:00:00 2001 From: Jason Evans Date: Sat, 29 Oct 2016 22:55:08 -0700 Subject: [PATCH] Use CLOCK_MONOTONIC_COARSE rather than COARSE_MONOTONIC_RAW. The raw clock variant is slow (even relative to plain CLOCK_MONOTONIC), whereas the coarse clock variant is faster than CLOCK_MONOTONIC, but still has resolution (~1ms) that is adequate for our purposes. This resolves #479. --- configure.ac | 12 ++++++------ .../jemalloc/internal/jemalloc_internal_defs.h.in | 4 ++-- src/nstime.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index 2dff55b2..b2616b9a 100644 --- a/configure.ac +++ b/configure.ac @@ -1312,16 +1312,16 @@ if test "x$je_cv_cray_prgenv_wrapper" = "xyes" ; then fi fi -dnl check for CLOCK_MONOTONIC_RAW (Linux-specific). -JE_COMPILABLE([clock_gettime(CLOCK_MONOTONIC_RAW, ...)], [ +dnl check for CLOCK_MONOTONIC_COARSE (Linux-specific). +JE_COMPILABLE([clock_gettime(CLOCK_MONOTONIC_COARSE, ...)], [ #include ], [ struct timespec ts; - clock_gettime(CLOCK_MONOTONIC_RAW, &ts); -], [je_cv_clock_monotonic_raw]) -if test "x${je_cv_clock_monotonic_raw}" = "xyes" ; then - AC_DEFINE([JEMALLOC_HAVE_CLOCK_MONOTONIC_RAW]) + clock_gettime(CLOCK_MONOTONIC_COARSE, &ts); +], [je_cv_clock_monotonic_coarse]) +if test "x${je_cv_clock_monotonic_coarse}" = "xyes" ; then + AC_DEFINE([JEMALLOC_HAVE_CLOCK_MONOTONIC_COARSE]) fi dnl check for CLOCK_MONOTONIC. diff --git a/include/jemalloc/internal/jemalloc_internal_defs.h.in b/include/jemalloc/internal/jemalloc_internal_defs.h.in index 70b32871..0ba960ba 100644 --- a/include/jemalloc/internal/jemalloc_internal_defs.h.in +++ b/include/jemalloc/internal/jemalloc_internal_defs.h.in @@ -77,9 +77,9 @@ #undef JEMALLOC_HAVE_ISSETUGID /* - * Defined if clock_gettime(CLOCK_MONOTONIC_RAW, ...) is available. + * Defined if clock_gettime(CLOCK_MONOTONIC_COARSE, ...) is available. */ -#undef JEMALLOC_HAVE_CLOCK_MONOTONIC_RAW +#undef JEMALLOC_HAVE_CLOCK_MONOTONIC_COARSE /* * Defined if clock_gettime(CLOCK_MONOTONIC, ...) is available. diff --git a/src/nstime.c b/src/nstime.c index c420c88d..0948e29f 100644 --- a/src/nstime.c +++ b/src/nstime.c @@ -110,14 +110,14 @@ nstime_get(nstime_t *time) nstime_init(time, ticks_100ns * 100); } -#elif JEMALLOC_HAVE_CLOCK_MONOTONIC_RAW +#elif JEMALLOC_HAVE_CLOCK_MONOTONIC_COARSE # define NSTIME_MONOTONIC true static void nstime_get(nstime_t *time) { struct timespec ts; - clock_gettime(CLOCK_MONOTONIC_RAW, &ts); + clock_gettime(CLOCK_MONOTONIC_COARSE, &ts); nstime_init2(time, ts.tv_sec, ts.tv_nsec); } #elif JEMALLOC_HAVE_CLOCK_MONOTONIC