]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stick-table: move the task_wakeup() call outside of the lock
authorWilly Tarreau <w@1wt.eu>
Sat, 27 May 2023 18:35:15 +0000 (18:35 +0000)
committerWilly Tarreau <w@1wt.eu>
Fri, 11 Aug 2023 17:03:35 +0000 (19:03 +0200)
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.

src/stick_table.c

index ba6e3c430883fd1ef25cb9059ac5a492b3fa15d2..ae6b79f605b76387fa5375f00cd266ad2df4573a 100644 (file)
@@ -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 <ts> but do not touch its expiration node.