Steven Barrett commented on issue #106 at Alfred Chen / linux-prjc

Steven Barrett
2025-03-29T14:21:26Z

Testing this issue on multiple systems, it appears that there may be an artificial limit on the max amount of context switches per second, per process.

Both on a 5950x (16c, 32t, <220w), and a 8565u (4c, 8t, <35w), I can only achieve just under 900-850k context switches for the test duration of 30 seconds. The actual command extracted by running ps is:

stress-ng -t 30 --metrics-brief --switch -1 --no-rand-seed

This command launches a stressor for each available SMT thread with a duration of 30 seconds and outputs a result at the end. From the phoronix-test-suite output, we get on the 5950x a worse result than the CPU with a quarter of the threads (32t -> 8t):

Stress-NG 0.18.09:
pts/stress-ng-1.13.0 [Test: Context Switching]
Test 1 of 1
Estimated Trial Run Count: 3
Estimated Time To Completion: 2 Minutes [14:14 UTC]
Started Run 1 @ 14:13:10
Started Run 2 @ 14:13:44
Started Run 3 @ 14:14:18

Test: Context Switching:
798608.06
789806.78
815434.76

Average: 801283.20 Bogo Ops/s
Deviation: 1.63%

Comparison of 206 OpenBenchmarking.org samples since 14 January; median result: 7220588 Bogo Ops/s. Box plot of samples:
[###!####----*---------------*-------*---------*-------------------------------------------|* ]
^ AMD Ryzen Threadripper 7980X: 22315894 2 x AMD EPYC 9755: 159969324 ^
AMD EPYC 9845: 80979672 ^
AMD EPYC 9655P: 64248407 ^
^ AMD EPYC 9575F: 49534976

The ! is where we land in the general historical testing of things, and it's far below where it should be.

As for the socket activity test, even though it's not as bad (4-5x worse rather than 15x), it makes the entire system unresponsive during testing:

stress-ng -t 30 --metrics-brief --sock -1 --no-rand-seed --sock-zerocopy

My theory is that these two issues explain the other anomalies in the Phoronix report mentioned in the original description. And although these are synthetic benchmarks that stress very specific aspects of the scheduler, regular programs may benefit from an improvement in these areas as the 99th percentile or other outlier metrics that get perceived as jank or stutter in gaming, desktop responsiveness during heavy background tasks, etc.