]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stream: don't update s->lat_time when the wakeup date is not set
authorWilly Tarreau <w@1wt.eu>
Tue, 19 Nov 2024 15:42:40 +0000 (16:42 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 19 Nov 2024 19:13:41 +0000 (20:13 +0100)
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

index 000a4c3fc5add7589bb67b96527d838cb7134bec..fd9a0272111ebf29d4a62954590340086e5bde28 100644 (file)
@@ -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;
 }