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.
This commit is contained in:
Willy Tarreau 2022-06-14 15:04:34 +02:00
parent 3ccb14d60d
commit f5aef027ce
1 changed files with 4 additions and 2 deletions

View File

@ -297,8 +297,10 @@ void wake_expired_tasks()
struct eb32_node *eb;
__decl_thread(int key);
while (max_processed-- > 0) {
lookup_next_local:
while (1) {
if (max_processed-- <= 0)
goto leave;
eb = eb32_lookup_ge(&tt->timers, now_ms - TIMER_LOOK_BACK);
if (!eb) {
/* we might have reached the end of the tree, typically because