From 2e31277207f5f256e9cb31c26b2341d353878009 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Tue, 20 Jun 2023 22:18:41 +0200 Subject: [PATCH] Disable lazy gettimeofday/clock_gettime comparison The benefit of this optimization is questionable for the following reasons: - libevent uses CLOCK_MONOTONIC_COARSE which is fast enough (on my desktop CLOCK_MONOTONIC/CLOCK_MONOTONIC_RAW works 40/50 millions of ops per second, and CLOCK_MONOTONIC_COARSE is faster) - libevent has caching of time (EVENT_BASE_FLAG_NO_CACHE_TIME) So I don't see any reason for using one more caching - lazy comparsion (whatever you call it). --- event.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/event.c b/event.c index 9b205400..bf50ff84 100644 --- a/event.c +++ b/event.c @@ -409,7 +409,7 @@ static void event_debug_assert_socket_nonblocking_(evutil_socket_t fd) { (void)f /* How often (in seconds) do we check for changes in wall clock time relative * to monotonic time? Set this to -1 for 'never.' */ -#define CLOCK_SYNC_INTERVAL 5 +#define CLOCK_SYNC_INTERVAL -1 /** Set 'tp' to the current time according to 'base'. We must hold the lock * on 'base'. If there is a cached time, return it. Otherwise, use @@ -2770,7 +2770,6 @@ event_add_nolock_(struct event *ev, const struct timeval *tv, event_queue_remove_active(base, event_to_event_callback(ev)); } - base->last_updated_clock_diff = 0; // force diff recalc for correct ev->ev_timeout calculation gettime(base, &now); common_timeout = is_common_timeout(tv, base);