Page MenuHomeFreeBSD

sched_ule: Recover previous nice and anti-starvation behaviors
Needs ReviewPublic

Authored by olce on Sep 6 2024, 1:51 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 11, 4:08 AM
Unknown Object (File)
Tue, Oct 22, 5:29 PM
Unknown Object (File)
Tue, Oct 22, 9:42 AM
Unknown Object (File)
Thu, Oct 17, 8:30 AM
Unknown Object (File)
Oct 3 2024, 5:09 AM
Unknown Object (File)
Oct 2 2024, 3:33 PM
Unknown Object (File)
Sep 21 2024, 11:56 AM
Unknown Object (File)
Sep 17 2024, 3:30 PM
Subscribers

Details

Reviewers
jeff
mav
markj
jhb
Summary

Justification for this change is to avoid disturbing ULE's behavior too
much at this time. We however acknowledge that the effect of "nice"
values is extremely weak and will most probably change going forward.

Tuning allows to mostly recover ULE's behavior prior to the switch to
a single 256-queue runqueue and the increase of the timesharing priority
levels' range.

After this change, in a series of test involving two long-running
processes with varying nice values competing for the same CPU, we
observe that used CPU time ratios of the highest priority process to
change by at most 1.15% and on average by 0.46% (absolute differences).
In relative differences, they change by at most 2% and on average by
0.78%.

In order to preserve these ratios, as the number of priority levels
alloted to the timesharing policy have been raised from 136 to 168, we
keep the ratio of levels reserved to handle nice values to that
reserved for CPU usage by applying a factor of 5/4 (which is close to
168/136).

Time-based advance of the timesharing circular queue's head is ULE's
main fairness and anti-starvation mechanism. The higher number of
timesharing queues is now compensated by allowing a greater increment of
the head offset per tick. Because there are now 112 queue levels
dedicated to the timesharing policy, whereas there previously were 64
(priorities spread into a single, separate runqueue), the circular
queue's head must progress 7/4 faster.

While here, take into 'cnt' as the number of ticks when advancing the
circular queue's head. This fix depends on the other code changes
enabling incrementation by more than one.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 59349
Build 56236: arc lint + arc unit

Event Timeline

olce requested review of this revision.Sep 6 2024, 1:51 PM

Some results of conducted tests with two threads whose processes have different nice values forced on the same core, reporting the achieved %CPU ratio over periods of more than 1 minute as reported by ps using mainly etime and time:

-CURRENT

  • 0 vs 20 : 54.37% (3:18.47 vs 2:46.55)
  • -2 vs 20 : 55.51% (1:52.43 vs 1:30.11)
  • -4 vs 20 : 57.62% (1:22.77 vs 1:00.87)
  • -6 vs 20 : 59.93% (7:17.71 vs 4:52.70)
  • -8 vs 20 : 61.54% (3:36.98 vs 2:15.60)
  • -10 vs 20 : 63.30% (28:56.20 vs 16:46.66)
  • -12 vs 20 : 65.35% (10:11.64 vs 5:24.35)
  • -14 vs 20 : 66.66% (3:12.28 vs 1:36.19)
  • -16 vs 20 : 66.70% (2:41.02 vs 1:20.38)
  • -20 vs 20 : 66.76% (3:21.77 vs 1:40.45)

With this series of patches:

  • 0 vs 20 : 54.93% (2:03.79 vs 1:41.56)
  • -2 vs 20 : 55.17% (25:08.27 vs 20:25.73)
  • -4 vs 20 : 56.47% (19:18.32 vs 14:53.06)
  • -6 vs 20 : 59.63% (9:13.80 vs 6:14.87)
  • -8 vs 20 : 61.76% (3:02.38 vs 1:52.93)
  • -10 vs 20 : 64.26% (31:40.02 vs 17:36.76)
  • -12 vs 20 : 65.37% (50:07.73 vs 26:33.36)
  • -20 vs 20 : 66.72% (5:45.09 vs 2:52.14)