From c9afbb10f5430ffce9aacd020ef46522d7e675cc Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 25 Feb 2021 07:19:45 +0100 Subject: [PATCH] MINOR: task: don't decrement then increment the local run queue 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/task.c b/src/task.c index df6fbd5..b205432 100644 --- a/src/task.c +++ b/src/task.c @@ -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; } -- 1.7.10.4