]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: tasks: clean up the front side of the wait queue in wake_expired_tasks()
authorWilly Tarreau <w@1wt.eu>
Fri, 19 Jun 2020 09:50:27 +0000 (11:50 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 19 Jun 2020 12:21:46 +0000 (14:21 +0200)
commit77015abe0bcfde67bff519b1d48393a513015f77
tree3d9fa22a6ac8b8133e9e7f69112f006a4adfde8a
parenta7ad4aed6086995b4727777859be3f717295b7f1
MEDIUM: tasks: clean up the front side of the wait queue in wake_expired_tasks()

Due to the way the wait queue works, some tasks might be postponed but not
requeued. However when we exit wake_expired_tasks() on a not-yet-expired
task and leave it in this situation, the next call to next_timer_expiry()
will use this first task's key in the tree as an expiration date, but this
date might be totally off and cause needless wakeups just to reposition it.

This patch makes sure that we leave wake_expired_tasks with a clean state
of frontside tasks and that their tree's key matches their expiration date.
Doing so we can already observe a ~15% reduction of the number of wakeups
when dealing with large numbers of health checks.

The patch looks large because the code was rearranged but the real change
is to take the wakeup/requeue decision on the task's expiration date instead
of the tree node's key, the rest is unchanged.
src/task.c