All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] [tip: sched/core] sched: Disable PLACE_LAG and RUN_TO_PARITY and move them to sysctl
@ 2024-10-17  5:19 Cristian Prundeanu
  2024-10-17  5:19 ` [PATCH 1/2] [tip: sched/core] sched: Disable PLACE_LAG and RUN_TO_PARITY Cristian Prundeanu
                   ` (4 more replies)
  0 siblings, 5 replies; 26+ messages in thread
From: Cristian Prundeanu @ 2024-10-17  5:19 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, x86, linux-arm-kernel,
	Bjoern Doebel, Hazem Mohamed Abuelfotoh, Geoff Blake, Ali Saidi,
	Csaba Csoma, Cristian Prundeanu

This patchset disables the scheduler features PLACE_LAG and RUN_TO_PARITY 
and moves them to sysctl.

Replacing CFS with the EEVDF scheduler in kernel 6.6 introduced 
significant performance degradation in multiple database-oriented 
workloads. This degradation manifests in all kernel versions using EEVDF, 
across multiple Linux distributions, hardware architectures (x86_64, 
aarm64, amd64), and CPU generations.

For example, running mysql+hammerdb results in a 12-17% throughput 
reduction and 12-18% latency increase compared to kernel 6.5 (using 
default scheduler settings everywhere). The magnitude of this performance 
impact is comparable to the average performance difference of a CPU 
generation over its predecessor.

Testing combinations of available scheduler features showed that the 
largest improvement (short of disabling all EEVDF features) came from 
disabling both PLACE_LAG and RUN_TO_PARITY:

Kernel   | default  | NO_PLACE_LAG and
aarm64   | config   | NO_RUN_TO_PARITY
---------+----------+-----------------
6.5      | baseline |  N/A
6.6      | -13.2%   | -6.8%
6.7      | -13.1%   | -6.0%
6.8      | -12.3%   | -6.5%
6.9      | -12.7%   | -6.9%
6.10     | -13.5%   | -5.8%
6.11     | -12.6%   | -5.8%
6.12-rc2 | -12.2%   | -8.9%
---------+----------+-----------------

Kernel   | default  | NO_PLACE_LAG and
x86_64   | config   | NO_RUN_TO_PARITY
---------+----------+-----------------
6.5      | baseline |  N/A
6.6      | -16.8%   | -10.8%
6.7      | -16.4%   |  -9.9%
6.8      | -17.2%   |  -9.5%
6.9      | -17.4%   |  -9.7%
6.10     | -16.5%   |  -9.0%
6.11     | -15.0%   |  -8.5%
6.12-rc2 | -12.7%   | -10.9%
---------+----------+-----------------

While the long term approach is debugging and fixing the scheduler 
behavior, algorithm changes to address performance issues of this nature 
are specialized (and likely prolonged or open-ended) research. Until a 
change is identified which fixes the performance degradation, in the 
interest of a better out-of-the-box performance: (1) disable these 
features by default, and (2) expose these values in sysctl instead of 
debugfs, so they can be more easily persisted across reboots.

Cristian Prundeanu (2):
  sched: Disable PLACE_LAG and RUN_TO_PARITY
  sched: Move PLACE_LAG and RUN_TO_PARITY to sysctl

 include/linux/sched/sysctl.h |  8 ++++++++
 kernel/sched/core.c          | 13 +++++++++++++
 kernel/sched/fair.c          |  5 +++--
 kernel/sched/features.h      | 10 ----------
 kernel/sysctl.c              | 20 ++++++++++++++++++++
 5 files changed, 44 insertions(+), 12 deletions(-)

-- 
2.40.1


^ permalink raw reply	[flat|nested] 26+ messages in thread
* Re: [PATCH 0/2] [tip: sched/core] sched: Disable PLACE_LAG and RUN_TO_PARITY and move them to sysctl
@ 2024-10-19  2:30 Prundeanu, Cristian
  2024-10-24  8:12 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 26+ messages in thread
From: Prundeanu, Cristian @ 2024-10-19  2:30 UTC (permalink / raw)
  To: K Prateek Nayak, Peter Zijlstra
  Cc: linux-tip-commits@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ingo Molnar, x86@kernel.org, linux-arm-kernel@lists.infradead.org,
	Doebel, Bjoern, Mohamed Abuelfotoh, Hazem, Blake, Geoff,
	Saidi, Ali, Csoma, Csaba, gautham.shenoy@amd.com

On 2024-10-18, 02:08, "K Prateek Nayak" <kprateek.nayak@amd.com> wrote:

> Most of our testing used sysbench as the benchmark driver. How does
> mysql+hammerdb work specifically? Do the tasks driving the request are
> located on a separate server or are co-located with the benchmarks
> threads on the same server?

The hammerdb test is a bit more complex than sysbench. It uses two
independent physical machines to perform a TPC-C derived test [1], aiming
to simulate a real-world database workload. The machines are allocated as
an AWS EC2 instance pair on the same cluster placement group [2], to avoid
measuring network bottlenecks instead of server performance. The SUT
instance runs mysql configured to use 2 worker threads per vCPU (32
total); the load generator instance runs hammerdb configured with 64
virtual users and 24 warehouses [3]. Each test consists of multiple
20-minute rounds, run consecutively on multiple independent instance
pairs.

[1] https://www.tpc.org/tpcc/default5.asp
[2] https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/placement-strategies.html
[3] https://hammerdb.com/docs/ch03s05.html

> Did you see any glaring changes in scheduler statistics with the
> introduction of EEVDF in v6.6? EEVDF commits up till v6.9 were easy to
> revert from my experience but I've not tried it on v6.12-rcX with the
> EEVDF complete series. Is all the regression seen purely
> attributable to EEVDF alone on the more recent kernels?

Yes, the regression is attributable to EEVDF:
After seeing indications that there was a performance degradation
somewhere after kernel 6.5, bisect testing narrowed the same degradation
to merge commit b41bbb33cf75 (Merge branch 'sched/eevdf' into sched/core).
Expanding testing to all stable kernel versions next (6.6 through 6.11)
showed very similar performance data, confirming that non-EEDVF changes
introduced along the way do not have any significant impact.

Testing kernel 6.12 at various stages, starting with commit 2004cef11ea0
(Merge tag 'sched-core-2024-09-19') and continuing with the v6.12-rcX tags
as they became available, shows a different performance profile than
previous kernels: the degradation is smaller than 6.6 through 6.11, but
the positive impact from disabling PLACE_LAG and RUN_TO_PARITY is also
smaller. However, after testing a fractional factorial of combinations for
all EEVDF-specific features, the only configuration that yielded better
performance than NO_PLACE_LAG+NO_RUN_TO_PARITY was with all 7 features
disabled (NO_PLACE_LAG, NO_RUN_TO_PARITY, NO_DELAY_DEQUEUE, NO_DELAY_ZERO,
NO_PLACE_DEADLINE_INITIAL, NO_PLACE_REL_DEADLINE, NO_PREEMPT_SHORT). After
considering the potential impact on other workloads and the ease of
backporting for the two best options, NO_PLACE_LAG+NO_RUN_TO_PARITY seemed
like the better choice for 6.12 as well.

Looking at the comparative aperf [4] reports showed no diverging
configuration issues, and no noticeable differences in the PMU stats
(which confirms there are no unrelated system differences affecting the
results).

[4] https://github.com/aws/aperf

>> I haven't tested with SCHED_BATCH yet, will update the thread with results
>> as they accumulate

Testing with SCHED_BATCH (and default scheduler settings) resulted in no
significant performance change.

As an additional data point, using SCHED_FIFO or SCHED_RR further degraded
the mysql performance (but improved postgresql).

> Could you also test running with:
> echo NO_WAKEUP_PREEMPTION > /sys/kernel/debug/sched/features

Certainly; will update the thread when the results are available.   

> On a side note, what is the CONFIG_HZ and the
> preemption model on your test kernel (most of my testing was with
> CONFIG+HZ=250, voluntary preemption)

CONFIG_HZ was 250. Testing with other values did not reveal anything
relevant to this regression either: both CFS and EEVDF had a slight
improvement with CONFIG_HZ=100, and no change otherwise.

Preemption was the default (voluntary) for all tests.

> The data in the latter link helped root-cause the actual issue with the
> algorithm that the benchmark disliked. Similar information for the
> database benchmarks you are running, can help narrow down the issue.

Thank you for the links! I'll gladly continue gathering data and help 
diagnose this issue. I am concerned, however, with keeping the default 
configuration the way it currently is while the investigation continues.

Do you happen to know how the reported blogbench performance compares to 
the pre-EEVDF (v6.5) results?

> From what I can tell, your benchmark has a set of threads that like to
> get cpu time as fast as possible. With EEVDF Complete (I would recommend
> using current tip:sched/urgent branch to test them out) setting a more
> aggressive nice value to these threads should enable them to negate the
> effect of RUN_TO_PARITY thanks to PREEMPT_SHORT.
>
> As for NO_PLACE_LAG, the DELAY_DEQUEUE feature should help task shed off
> any lag it has built up and should very likely start from the zero-lag
> point unless it is a very short sleeper.

Agree with the thread assessment. It seems that the best outcome is when
the threads run as fast as possible, with overhead as small as possible. 

I'll test with EEVDF complete as well. Note that both DELAY_DEQUEUE and
PREEMPT_SHORT were part of the combinations in the test suite on commit
2004cef11ea0, as mentioned above, and did not effect dramatic performance
changes when flipped.
At that time (and this is no longer true in v6.12-rc2) NO_DELAY_ZERO was
also needed along with NO_PLACE_LAG and NO_RUN_TO_PARITY.

> Is there any reason to flip it very early into the boot? Have you seen
> anything go awry with system processes during boot with EEVDF?

I haven't, as this benchmarking is specifically measuring the stable state
of a system.
The boot order argument was only in the context of discussing the
suitability of rc.local as compared to sysctl for persisting scheduler
options. It's conceivable that options which are different in a stable
state than at startup could lead to process management outcomes which
affect performance (and are harder to reproduce scenarios).


^ permalink raw reply	[flat|nested] 26+ messages in thread
* [GIT PULL] sched/urgent for v6.13
@ 2025-01-19 11:04 Borislav Petkov
  0 siblings, 0 replies; 26+ messages in thread
From: Borislav Petkov @ 2025-01-19 11:04 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: x86-ml, lkml

Hi Linus,

please pull the final sched/urgent lineup for v6.13.

Thx.

---

The following changes since commit eea6e4b4dfb8859446177c32961c96726d0117be:

  Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi (2025-01-08 11:55:20 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip tags/sched_urgent_for_v6.13

for you to fetch changes up to 66951e4860d3c688bfa550ea4a19635b57e00eca:

  sched/fair: Fix update_cfs_group() vs DELAY_DEQUEUE (2025-01-13 13:50:56 +0100)

----------------------------------------------------------------
- Do not adjust the weight of empty group entities and avoid scheduling
  artifacts

- Avoid scheduling lag by computing lag properly and thus address an EEVDF
  entity placement issue

----------------------------------------------------------------
Peter Zijlstra (2):
      sched/fair: Fix EEVDF entity placement bug causing scheduling lag
      sched/fair: Fix update_cfs_group() vs DELAY_DEQUEUE

 kernel/sched/fair.c | 151 ++++++++--------------------------------------------
 1 file changed, 23 insertions(+), 128 deletions(-)


-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

^ permalink raw reply	[flat|nested] 26+ messages in thread
* Re: [PATCH 0/2] [tip: sched/core] sched: Disable PLACE_LAG and RUN_TO_PARITY and move them to sysctl
@ 2025-01-28 23:09 Cristian Prundeanu
  2025-02-11  3:27 ` K Prateek Nayak
  0 siblings, 1 reply; 26+ messages in thread
From: Cristian Prundeanu @ 2025-01-28 23:09 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: cpru, kprateek.nayak, abuehaze, alisaidi, benh, blakgeof, csabac,
	doebel, gautham.shenoy, joseph.salisbury, dietmar.eggemann,
	linux-arm-kernel, linux-kernel, linux-tip-commits, mingo, x86,
	torvalds, bp

Peter,

Thank you for the recent scheduler rework which went into kernel 6.13. 
Here are the latest test results using mysql+hammerdb, using a standalone 
reproducer (details and instructions below).

Kernel | Runtime      | Throughput | P50 latency
aarm64 | parameters   | (NOPM)     | (larger is worse)
-------+--------------+------------+------------------
6.5    | default      |  baseline  |  baseline
-------+--------------+------------+------------------
6.8    | default      |  -6.9%     |  +7.9%
       | NO_PL NO_RTP |  -1%       |  +1%
       | SCHED_BATCH  |  -9%       |  +10.7%
-------+--------------+------------+------------------
6.12   | default      |  -5.5%     |  +6.2%
       | NO_PL NO_RTP |  -0.4%     |  +0.1%
       | SCHED_BATCH  |  -4.1%     |  +4.9%
-------+--------------+------------+------------------
6.13   | default      |  -4.8%     |  +5.4%
       | NO_PL NO_RTP |  -0.3%     |  +0.01%
       | SCHED_BATCH  |  -4.8%     |  +5.4%
-------+--------------+------------+------------------

A performance improvement is noticeable in kernel 6.13 over 6.12, both in 
latency and throughput. At the same time, SCHED_BATCH no longer has the 
same positive effect it had in 6.12.

Disabling PLACE_LAG and RUN_TO_PARITY is still as effective as before. 
For this reason, I'd like to ask once again that this patch set be 
considered for merging and for backporting to kernels 6.6+.

> This patchset disables the scheduler features PLACE_LAG and RUN_TO_PARITY 
> and moves them to sysctl.
>
> Replacing CFS with the EEVDF scheduler in kernel 6.6 introduced 
> significant performance degradation in multiple database-oriented 
> workloads. This degradation manifests in all kernel versions using EEVDF, 
> across multiple Linux distributions, hardware architectures (x86_64, 
> aarm64, amd64), and CPU generations.

When weighing the relevance of various testing approaches, please keep in 
mind that mysql is a real-life workload, while the test which prompted the 
introduction of PLACE_LAG is much closer to a synthetic benchmark.


Instructions for reproducing the above tests:

1. Code: The repro scenario that was used for this round of testing can be 
found here: https://github.com/aws/repro-collection

2. Setup: I used a 16 vCPU / 32G RAM / 1TB RAID0 SSD instance as SUT, 
running Ubuntu 22.04 with the latest updates. All kernels were compiled 
from source, preserving the same config (as much as possible) to minimize 
noise - in particular, CONFIG_HZ=250 was used everywhere.

3. Running: To run the repro, set up a SUT machine and a LDG (loadgen) 
machine on the same network, clone the git repo on both, and run:

(on the SUT) ./repro.sh repro-mysql-EEVDF-regression SUT --ldg=<loadgen_IP> 

(on the LDG) ./repro.sh repro-mysql-EEVDF-regression LDG --sut=<SUT_IP>

The repro will build and test multiple combinations of kernel versions and 
scheduler settings, and will prompt you when to reboot the SUT and rerun 
the same command to continue the process.

More instructions can be found both in the repo's README and by running 
'repro.sh --help'.

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2025-02-12  9:43 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-17  5:19 [PATCH 0/2] [tip: sched/core] sched: Disable PLACE_LAG and RUN_TO_PARITY and move them to sysctl Cristian Prundeanu
2024-10-17  5:19 ` [PATCH 1/2] [tip: sched/core] sched: Disable PLACE_LAG and RUN_TO_PARITY Cristian Prundeanu
2024-10-17  5:20 ` [PATCH 2/2] [tip: sched/core] sched: Move PLACE_LAG and RUN_TO_PARITY to sysctl Cristian Prundeanu
2024-10-17  9:10 ` [PATCH 0/2] [tip: sched/core] sched: Disable PLACE_LAG and RUN_TO_PARITY and move them " Peter Zijlstra
2024-10-17 18:19   ` Prundeanu, Cristian
2024-10-18  7:07     ` K Prateek Nayak
2024-10-18  9:54     ` Mohamed Abuelfotoh, Hazem
2024-11-14 20:10 ` Joseph Salisbury
2024-11-19 10:29   ` Dietmar Eggemann
2024-11-25 11:35 ` Cristian Prundeanu
2024-11-26  3:58   ` K Prateek Nayak
2024-11-26 15:12   ` Dietmar Eggemann
2024-11-28 10:32   ` Cristian Prundeanu
2024-11-29 10:12     ` Dietmar Eggemann
  -- strict thread matches above, loose matches on Subject: below --
2024-10-19  2:30 Prundeanu, Cristian
2024-10-24  8:12 ` Benjamin Herrenschmidt
2024-10-25 14:43   ` Gautham R. Shenoy
2024-10-29  4:57     ` Cristian Prundeanu
2024-10-30 10:21       ` Dietmar Eggemann
2024-11-01 13:05       ` Peter Zijlstra
2024-11-04 10:19       ` Gautham R. Shenoy
2024-11-04 10:34         ` K Prateek Nayak
2025-01-19 11:04 [GIT PULL] sched/urgent for v6.13 Borislav Petkov
2025-01-28 23:09 [PATCH 0/2] [tip: sched/core] sched: Disable PLACE_LAG and RUN_TO_PARITY and move them to sysctl Cristian Prundeanu
2025-02-11  3:27 ` K Prateek Nayak
2025-02-12  5:41   ` Cristian Prundeanu
2025-02-12  9:43     ` Peter Zijlstra

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.