From: Willy Tarreau Date: Tue, 19 Nov 2024 15:42:40 +0000 (+0100) Subject: MINOR: stream: don't update s->lat_time when the wakeup date is not set X-Git-Tag: v3.1-dev14~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=33c461314c7dbd24565fcc0c0a795fc779618bf3;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/src/stream.c b/src/stream.c index 000a4c3fc5..fd9a027211 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; }