]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MAJOR: polling: Use active_appels_mask instead of applets_active_queue
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 14 Nov 2017 10:30:47 +0000 (11:30 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 16 Nov 2017 10:19:46 +0000 (11:19 +0100)
applets_active_queue is the active queue size. It is a global variable. So it is
underoptimized because we may be lead to consider there are active applets for a
thread while in fact all active applets are assigned to the otherthreads. So, in
such cases, the polling loop will be evaluated many more times than necessary.

Instead, we now check if the thread id is set in the bitfield active_applets_mask.

This is specific to threads, no backport is needed.

src/applet.c
src/haproxy.c

index e24f66d05c01b13117a3fdf267ed385924a8b8f0..84ffde6b834fa0f55671a20cf1c42247694ebc8a 100644 (file)
@@ -33,10 +33,11 @@ void applet_run_active()
        struct stream_interface *si;
        struct list applet_cur_queue = LIST_HEAD_INIT(applet_cur_queue);
 
-       if (!applets_active_queue)
-               return;
-
        HA_SPIN_LOCK(APPLETS_LOCK, &applet_active_lock);
+       if (!(active_applets_mask & tid_bit)) {
+               HA_SPIN_UNLOCK(APPLETS_LOCK, &applet_active_lock);
+               return;
+       }
 
        curr = LIST_NEXT(&applet_active_queue, typeof(curr), runq);
        while (&curr->runq != &applet_active_queue) {
index 8f33e2695aecb9edc927e9146fbe94189e95a9d6..ba5a4b208553f14cf67aeebf4c4ca6399212801e 100644 (file)
@@ -2307,7 +2307,7 @@ static void run_poll_loop()
                        break;
 
                /* expire immediately if events are pending */
-               if (fd_cache_num || (active_tasks_mask & tid_bit) || signal_queue_len || applets_active_queue)
+               if (fd_cache_num || (active_tasks_mask & tid_bit) || signal_queue_len || (active_applets_mask & tid_bit))
                        next = now_ms;
 
                /* The poller will ensure it returns around <next> */