From 33c461314c7dbd24565fcc0c0a795fc779618bf3 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 19 Nov 2024 16:42:40 +0100 Subject: [PATCH] MINOR: stream: don't update s->lat_time when the wakeup date is not set In 2.7 was added a stream wakeup latency calculation with commit 6a28a30efa ("MINOR: tasks: do not keep cpu and latency times in struct task"). However, due to the transformation of the previous code, it kept unconditionally updating s->lat_time even of the sched_wake_date was zero. In other words, s->lat_time is constantly updated for the huge majority of calls that are made without profiling. Let's just check the sched_wake_date status before doing so. --- src/stream.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/stream.c b/src/stream.c index 000a4c3fc..fd9a02721 100644 --- a/src/stream.c +++ b/src/stream.c @@ -1639,8 +1639,12 @@ static void stream_handle_timeouts(struct stream *s) */ static void stream_cond_update_cpu_latency(struct stream *s) { - uint32_t lat = th_ctx->sched_call_date - th_ctx->sched_wake_date; + uint32_t lat; + if (likely(!th_ctx->sched_wake_date)) + return; + + lat = th_ctx->sched_call_date - th_ctx->sched_wake_date; s->lat_time += lat; }