From 4a8fbbd6d4e508c3e2b10cc8f03b4e85a40b4912 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 10 Mar 2021 09:26:24 +0100 Subject: [PATCH] MINOR: task: give the scheduler a bit more flexibility in the runqueue size Instead of setting a hard-limit on runqueue-depth and keeping it short to maintain fairness, let's allow the scheduler to automatically cut the existing one in two equal halves if its size is between the configured size and its double. This will allow to increase the default value while keeping a low latency. (cherry picked from commit 1691ba3693d4b11cc85aed606d39ffbd23d8533f) Signed-off-by: Willy Tarreau --- src/task.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/task.c b/src/task.c index 2959812..92d9630 100644 --- a/src/task.c +++ b/src/task.c @@ -591,6 +591,13 @@ void process_runnable_tasks() if (likely(niced_tasks)) max_processed = (max_processed + 3) / 4; + if (max_processed < sched->rq_total && sched->rq_total <= 2*max_processed) { + /* If the run queue exceeds the budget by up to 50%, let's cut it + * into two identical halves to improve latency. + */ + max_processed = sched->rq_total / 2; + } + not_done_yet: max[TL_URGENT] = max[TL_NORMAL] = max[TL_BULK] = 0; -- 1.7.10.4