diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-05-08 16:27:04 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-05-08 16:27:04 +0000 |
commit | a836a244a3d2bdd4da1ee2641e3e957850668cea (patch) | |
tree | cb87c75b3677fab7144f868435243f864048a1e6 /libnetdata/worker_utilization | |
parent | Adding upstream version 1.38.1. (diff) | |
download | netdata-a836a244a3d2bdd4da1ee2641e3e957850668cea.tar.xz netdata-a836a244a3d2bdd4da1ee2641e3e957850668cea.zip |
Adding upstream version 1.39.0.upstream/1.39.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libnetdata/worker_utilization')
-rw-r--r-- | libnetdata/worker_utilization/README.md | 6 | ||||
-rw-r--r-- | libnetdata/worker_utilization/worker_utilization.c | 16 |
2 files changed, 17 insertions, 5 deletions
diff --git a/libnetdata/worker_utilization/README.md b/libnetdata/worker_utilization/README.md index 35f30b40b..04dfb6215 100644 --- a/libnetdata/worker_utilization/README.md +++ b/libnetdata/worker_utilization/README.md @@ -1,6 +1,10 @@ <!-- title: "Worker Utilization" -custom_edit_url: https://github.com/netdata/netdata/edit/master/libnetdata/onewayallocator/README.md +custom_edit_url: https://github.com/netdata/netdata/edit/master/libnetdata/worker_utilization/README.md +sidebar_label: "Worker Utilization" +learn_status: "Published" +learn_topic_type: "References" +learn_rel_path: "Developers/libnetdata" --> # Worker Utilization diff --git a/libnetdata/worker_utilization/worker_utilization.c b/libnetdata/worker_utilization/worker_utilization.c index 8028e3a21..d47d81c4e 100644 --- a/libnetdata/worker_utilization/worker_utilization.c +++ b/libnetdata/worker_utilization/worker_utilization.c @@ -61,6 +61,14 @@ static struct workers_globals { static __thread struct worker *worker = NULL; // the current thread worker +static inline usec_t worker_now_monotonic_usec(void) { +#ifdef NETDATA_WITHOUT_WORKERS_LATENCY + return 0; +#else + return now_monotonic_usec(); +#endif +} + size_t workers_allocated_memory(void) { netdata_spinlock_lock(&workers_globals.spinlock); size_t memory = workers_globals.memory; @@ -77,7 +85,7 @@ void worker_register(const char *name) { worker->tag = strdupz(netdata_thread_tag()); worker->workname = strdupz(name); - usec_t now = now_monotonic_usec(); + usec_t now = worker_now_monotonic_usec(); worker->statistics_last_checkpoint = now; worker->last_action_timestamp = now; worker->last_action = WORKER_IDLE; @@ -181,14 +189,14 @@ static inline void worker_is_idle_with_time(usec_t now) { void worker_is_idle(void) { if(unlikely(!worker || worker->last_action != WORKER_BUSY)) return; - worker_is_idle_with_time(now_monotonic_usec()); + worker_is_idle_with_time(worker_now_monotonic_usec()); } void worker_is_busy(size_t job_id) { if(unlikely(!worker || job_id >= WORKER_UTILIZATION_MAX_JOB_TYPES)) return; - usec_t now = now_monotonic_usec(); + usec_t now = worker_now_monotonic_usec(); if(worker->last_action == WORKER_BUSY) worker_is_idle_with_time(now); @@ -260,7 +268,7 @@ void workers_foreach(const char *name, void (*callback)( struct worker *p; DOUBLE_LINKED_LIST_FOREACH_FORWARD(workname->base, p, prev, next) { - usec_t now = now_monotonic_usec(); + usec_t now = worker_now_monotonic_usec(); // find per job type statistics STRING *per_job_type_name[WORKER_UTILIZATION_MAX_JOB_TYPES]; |