OPTIM: task: do not consult shared WQ when we're already full
authorWilly Tarreau <w@1wt.eu>
Tue, 14 Jun 2022 13:04:34 +0000 (15:04 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 14 Jun 2022 14:15:15 +0000 (16:15 +0200)
commitf5aef027cefe3066a6546580e599734b174bcd5f
tree6d87bde72a6c10711d874e80dc3925c32c720d36
parent3ccb14d60d8768d8ba8dc029af2fe76e3801226f
OPTIM: task: do not consult shared WQ when we're already full

If we've stopped consulting the local wait queue due to too many tasks
(max_processed <= 0), there's no point starting to lock the shared WQ,
check the first task's expiration date, upgrading the lock just to
refrain from doing the work because of the limit. All this does is
increase contention on an already contended system.

Note that there is still a fairness issue in this WQ dequeuing code. If
each thread is busy with expired tasks, no thread will dequeue the global
ones. In practice it doesn't make much sense and should quickly resorb,
but it could be nice to have an alternating flag indicating where to
start from on next call to improve this.
src/task.c