From: Kayra Cizmeci <kayracizmeci@gmail.com>
To: Qing Wang <wangqing7171@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
K Prateek Nayak <kprateek.nayak@amd.com>,
Tim Chen <tim.c.chen@linux.intel.com>,
Chen Yu <yu.c.chen@intel.com>,
Davi Chaves Azevedo <davichazbh@gmail.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] sched/fair: Replace random newidle_balance with Bresenham accumulator
Date: Fri, 30 Oct 2026 17:47:45 +0300 [thread overview]
Message-ID: <auSo1jhKzD5vDNys@scheduler.schedules> (raw)
In-Reply-To: <20261030091946.2498870-1-wangqing7171@gmail.com>
On Fri, Oct 30, 2026 at 05:19:46PM +0800, Qing Wang wrote:
> The current NI_RANDOM implementation uses a random dice roll to allow
> newidle_balance attempts according to the success rate. This can be
> replaced with a Bresenham accumulator.
>
> Replace the random dice with a Bresenham accumulator. Each step does
> the following:
> - Accumulate (1 + newidle_ratio) into newidle_window_pos(accumulator).
> - If the accumulator reaches 1024, allow the balance attempt and
> subtract 1024.
>
> Why Bresenham:
> 1. It is deterministic and reproducible. For a given ratio, the
> balance frequency is exact and not subject to random variance,
> which makes the behavior predictable when debugging or tracing.
> 2. Bresenham spaces the attempts evenly; the random dice can go for
> a long stretch without balancing or fire several times in a row,
> especially at low ratios.
>
> A quick simulation where the ratio jumps to a random value in
> [0, 1023] every 512 calls (20000 windows):
>
> Bresenham random dice
> max per-window error 0.5 attempts 41 attempts
>
> The max per-window error is the max difference between the actual
> and expected number of attempts within a window; Bresenham's error
> is much smaller.
>
> Signed-off-by: Qing Wang <wangqing7171@gmail.com>
Hi Qing,
Tested on Zen 3 with tbench (8 cores, 16 threads) 5 runs:
C = Client, Higher is better. MB/s.
One boot per kernel.
-C--+--------(BASE)---------+-------(PATCH)---------
1 | 311.19 (0.00 pct) | 313.42 ( 0.72 pct)
8 | 2097.95 (0.00 pct) | 2113.36 ( 0.73 pct)
16 | 3271.83 (0.00 pct) | 3229.59 (-1.29 pct)
32 | 3341.13 (0.00 pct) | 3286.98 (-1.62 pct)
stddev:
-C--+-----(BASE)--+----(PATCH)--
1 | 0.93 | 1.07
8 | 8.35 | 10.24
16 | 15.06 | 7.56
32 | 2.92 | 4.04
There's a loss at 32 Clients. Some gain at 1 clients maybe.
Still, these results don’t show a performance gain for Bresenham,
no?
Thanks,
Kayra :-).
prev parent reply other threads:[~2026-10-30 14:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 9:19 Qing Wang
2026-10-30 9:46 ` K Prateek Nayak
2026-10-30 9:56 ` Peter Zijlstra
2026-10-30 10:22 ` Qing Wang
2026-10-30 10:39 ` Peter Zijlstra
2026-10-30 10:09 ` Qing Wang
2026-10-30 14:47 ` Kayra Cizmeci [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=auSo1jhKzD5vDNys@scheduler.schedules \
--to=kayracizmeci@gmail.com \
--cc=bsegall@google.com \
--cc=davichazbh@gmail.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tim.c.chen@linux.intel.com \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=wangqing7171@gmail.com \
--cc=yu.c.chen@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®