diff options
author | Lukáš Ondráček <lukas.ondracek@nic.cz> | 2025-01-09 17:38:21 +0100 |
---|---|---|
committer | Lukáš Ondráček <lukas.ondracek@nic.cz> | 2025-01-09 17:38:21 +0100 |
commit | a47ca64dd9ba1e37512d9ad6d1cbc70688ca0d24 (patch) | |
tree | 541af54b3701f9446861bac4ffa04f22b8ba1dd9 | |
parent | daemon/defer: fix accounting time to phases (diff) | |
download | knot-resolver-a47ca64dd9ba1e37512d9ad6d1cbc70688ca0d24.tar.xz knot-resolver-a47ca64dd9ba1e37512d9ad6d1cbc70688ca0d24.zip |
daemon/defer: update uv time after longer operations
-rw-r--r-- | daemon/defer.c | 1 | ||||
-rw-r--r-- | daemon/defer.h | 9 |
2 files changed, 8 insertions, 2 deletions
diff --git a/daemon/defer.c b/daemon/defer.c index 5a7df24c..b1abcacd 100644 --- a/daemon/defer.c +++ b/daemon/defer.c @@ -69,6 +69,7 @@ struct defer { }; struct defer *defer = NULL; bool defer_initialized = false; +uint64_t defer_uvtime_stamp = 0; struct mmapped defer_mmapped = {0}; defer_sample_state_t defer_sample_state = { diff --git a/daemon/defer.h b/daemon/defer.h index 06c9d56d..c5ae26c5 100644 --- a/daemon/defer.h +++ b/daemon/defer.h @@ -30,7 +30,7 @@ extern defer_sample_state_t defer_sample_state; extern struct defer *defer; /// skip sampling/deferring if NULL extern bool defer_initialized; /// defer_init was called, possibly keeping defer disabled - +extern uint64_t defer_uvtime_stamp; /// stamp of the last uv time update // TODO: reconsider `static inline` cases below @@ -39,7 +39,12 @@ static inline uint64_t defer_get_stamp(void) { struct timespec now_ts = {0}; clock_gettime(CLOCK_THREAD_CPUTIME_ID, &now_ts); - return now_ts.tv_nsec + 1000*1000*1000 * (uint64_t)now_ts.tv_sec; + uint64_t stamp = now_ts.tv_nsec + 1000*1000*1000 * (uint64_t)now_ts.tv_sec; + if (defer_uvtime_stamp + 1000*1000 < stamp) { + defer_uvtime_stamp = stamp; + uv_update_time(uv_default_loop()); + } + return stamp; } /// Annotate the work currently being accounted by an IP address. |