From: Willy Tarreau Date: Sat, 27 May 2023 18:35:15 +0000 (+0000) Subject: MINOR: stick-table: move the task_wakeup() call outside of the lock X-Git-Tag: v2.9-dev3~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=73b1dea4d104d38e22cc898cf12499a778bd754e;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/src/stick_table.c b/src/stick_table.c index ba6e3c4308..ae6b79f605 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -424,6 +424,7 @@ void stktable_touch_with_exp(struct stktable *t, struct stksess *ts, int local, { struct eb32_node * eb; int locked = 0; + int do_wakeup = 0; if (expire != HA_ATOMIC_LOAD(&ts->expire)) { /* 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); } } - task_wakeup(t->sync_task, TASK_WOKEN_MSG); + do_wakeup = 1; } else { /* 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) HA_RWLOCK_WRUNLOCK(STK_TABLE_LOCK, &t->lock); + + if (do_wakeup) + task_wakeup(t->sync_task, TASK_WOKEN_MSG); } /* Update the expiration timer for but do not touch its expiration node.