]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: applets: Don't process more than 200 active applets at once
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 15 Nov 2017 21:14:49 +0000 (22:14 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 16 Nov 2017 10:19:46 +0000 (11:19 +0100)
Now, we process at most 200 active applets per call to applet_run_active. We use
the same limit as the tasks. With the cache filter and the SPOE, the number of
active applets can now be huge. So, it is important to limit the number of
applets processed in applet_run_active.

src/applet.c

index 84ffde6b834fa0f55671a20cf1c42247694ebc8a..77f984d91f75c3e703c4c785e14c899c4faa9ad7 100644 (file)
@@ -32,13 +32,18 @@ void applet_run_active()
        struct appctx *curr, *next;
        struct stream_interface *si;
        struct list applet_cur_queue = LIST_HEAD_INIT(applet_cur_queue);
+       int max_processed;
+
+       max_processed = applets_active_queue;
+       if (max_processed > 200)
+               max_processed = 200;
 
        HA_SPIN_LOCK(APPLETS_LOCK, &applet_active_lock);
        if (!(active_applets_mask & tid_bit)) {
                HA_SPIN_UNLOCK(APPLETS_LOCK, &applet_active_lock);
                return;
        }
-
+       active_applets_mask &= ~tid_bit;
        curr = LIST_NEXT(&applet_active_queue, typeof(curr), runq);
        while (&curr->runq != &applet_active_queue) {
                next = LIST_NEXT(&curr->runq, typeof(next), runq);
@@ -47,10 +52,14 @@ void applet_run_active()
                        curr->state = APPLET_RUNNING;
                        LIST_ADDQ(&applet_cur_queue, &curr->runq);
                        applets_active_queue--;
+                       max_processed--;
                }
                curr = next;
+               if (max_processed <= 0) {
+                       active_applets_mask |= tid_bit;
+                       break;
+               }
        }
-       active_applets_mask &= ~tid_bit;
        HA_SPIN_UNLOCK(APPLETS_LOCK, &applet_active_lock);
 
        /* The list is only scanned from the head. This guarantees that if any