From: Willy Tarreau Date: Thu, 25 Feb 2021 06:19:45 +0000 (+0100) Subject: MINOR: task: don't decrement then increment the local run queue X-Git-Tag: v2.4-dev10~43 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c9afbb10f5430ffce9aacd020ef46522d7e675cc;p=thirdparty%2Fhaproxy.git 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). --- diff --git a/src/task.c b/src/task.c index df6fbd5c0f..b2054320e9 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; }