]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: task: don't decrement then increment the local run queue
authorWilly Tarreau <w@1wt.eu>
Thu, 25 Feb 2021 06:19:45 +0000 (07:19 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 25 Feb 2021 08:44:16 +0000 (09:44 +0100)
Now we don't need to decrement rq_total when we pick a tack in the tree
to immediately increment it again after installing it into the local
list. Instead, we simply add to the local queue count the number of
globally picked tasks. Avoiding this shows ~0.5% performance gains at
1Mreq/s (2M task switches/s).

src/task.c

index df6fbd5c0f6cb94e11b4be063aae5d98b3706d90..b2054320e97dbcea8fd62edc2d43877392009d01 100644 (file)
@@ -701,7 +701,6 @@ void process_runnable_tasks()
                if (likely(!grq || (lrq && (int)(lrq->key - grq->key) <= 0))) {
                        t = eb32sc_entry(lrq, struct task, rq);
                        lrq = eb32sc_next(lrq, tid_bit);
-                       _HA_ATOMIC_SUB(&sched->rq_total, 1);
                        eb32sc_delete(&t->rq);
                        lpicked++;
                }
@@ -739,7 +738,8 @@ void process_runnable_tasks()
        if (lpicked + gpicked) {
                tt->tl_class_mask |= 1 << TL_NORMAL;
                _HA_ATOMIC_ADD(&tt->tasks_in_list, lpicked + gpicked);
-               _HA_ATOMIC_ADD(&tt->rq_total, lpicked + gpicked);
+               if (gpicked)
+                       _HA_ATOMIC_ADD(&tt->rq_total, gpicked);
                activity[tid].tasksw += lpicked + gpicked;
        }