]> git.kaiwu.me - nginx.git/commitdiff
Removed CLOCK_MONOTONIC_FAST support.
authorEugene Grebenschikov <e.grebenshchikov@f5.com>
Wed, 1 Apr 2026 18:03:21 +0000 (11:03 -0700)
committerEugene <54681898+jimf5@users.noreply.github.com>
Fri, 3 Apr 2026 18:57:21 +0000 (11:57 -0700)
CLOCK_MONOTONIC_FAST, like CLOCK_MONOTONIC_COARSE, has low accuracy. It
shows noticeable timing variation for short intervals, which is visible
in metrics like $upstream_response_time for fast upstream responses.
This change complements the work started in commit f29d7ade5.
In addition to the reasons described in f29d7ade5, the performance of
CLOCK_MONOTONIC is good enough on modern hardware when using a TSC
timecounter. This is especially true when it is accessed through a
shared page, as implemented in FreeBSD 10.0 (see git commits
869fd80fd449 and aea810386d8e for details).

Co-authored-by: Sergey Kandaurov <pluknet@nginx.com>
src/core/ngx_times.c

index 16788c98cb2ed2a63ebfbdeea199b0d54d63435c..b0057d2abf292d0d28fa8e93d13342a4e438d8b1 100644 (file)
@@ -198,11 +198,7 @@ ngx_monotonic_time(time_t sec, ngx_uint_t msec)
 #if (NGX_HAVE_CLOCK_MONOTONIC)
     struct timespec  ts;
 
-#if defined(CLOCK_MONOTONIC_FAST)
-    clock_gettime(CLOCK_MONOTONIC_FAST, &ts);
-#else
     clock_gettime(CLOCK_MONOTONIC, &ts);
-#endif
 
     sec = ts.tv_sec;
     msec = ts.tv_nsec / 1000000;