MINOR: stick-table: move the task_wakeup() call outside of the lock

The write lock in stktable_touch_with_exp() is quite expensive and should
be shortened as much as possible. There's no need for it when calling
task_wakeup() so let's move it out.

On a 80-thread machine with a peers section, the request rate increased
from 397k to 415k rps.
This commit is contained in:
Willy Tarreau 2023-05-27 18:35:15 +00:00
parent 322e4ab9d2
commit 73b1dea4d1

View File

@ -424,6 +424,7 @@ void stktable_touch_with_exp(struct stktable *t, struct stksess *ts, int local,
{ {
struct eb32_node * eb; struct eb32_node * eb;
int locked = 0; int locked = 0;
int do_wakeup = 0;
if (expire != HA_ATOMIC_LOAD(&ts->expire)) { if (expire != HA_ATOMIC_LOAD(&ts->expire)) {
/* we'll need to set the expiration and to wake up the expiration timer .*/ /* we'll need to set the expiration and to wake up the expiration timer .*/
@ -452,7 +453,7 @@ void stktable_touch_with_exp(struct stktable *t, struct stksess *ts, int local,
eb32_insert(&t->updates, &ts->upd); eb32_insert(&t->updates, &ts->upd);
} }
} }
task_wakeup(t->sync_task, TASK_WOKEN_MSG); do_wakeup = 1;
} }
else { else {
/* If this entry is not in the tree */ /* If this entry is not in the tree */
@ -482,6 +483,9 @@ void stktable_touch_with_exp(struct stktable *t, struct stksess *ts, int local,
if (locked) if (locked)
HA_RWLOCK_WRUNLOCK(STK_TABLE_LOCK, &t->lock); HA_RWLOCK_WRUNLOCK(STK_TABLE_LOCK, &t->lock);
if (do_wakeup)
task_wakeup(t->sync_task, TASK_WOKEN_MSG);
} }
/* Update the expiration timer for <ts> but do not touch its expiration node. /* Update the expiration timer for <ts> but do not touch its expiration node.