Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scx_bpfland: introduce --lowlatency option #536

Merged
merged 1 commit into from
Aug 23, 2024
Merged

Conversation

arighi
Copy link
Contributor

@arighi arighi commented Aug 22, 2024

Introduce the new --lowlatency option, which enables switching between the default pure vruntime-based scheduling (more optimized for server workloads) and a deadline-based scheduling (better suited for low-latency workloads).

When the low-latency mode is activated, a task's deadline is calculated as its vruntime, adjusted by a bonus proportional to the task's average number of voluntary context switches (the more voluntary context switches, the shorter the deadline).

This feature enhances the prioritization of interactive tasks even more, proportionally to their average voluntary context switches, also within the two main global queues (priority / shared) and it helps to maintain interactive workloads always responsive, even in presence of heavy non-interactive background work.

Low-latency mode allows to prevent audio cracking even in presence of a large amount of short-lived tasks with pseudo-interactive behavior (i.e, hackbench) and it enables achieving approximately a +33% average frames-per-second (FPS) in the typical "gaming while building the kernel" benchmark.

However, it can also amplify the de-prioritization of CPU-intensive tasks, making this option more suitable for specific low-latency scenarios. Therefore the low-latency mode is disabled by default and it can only be enabled via the --lowlatency option.

Copy link
Contributor

@sirlucjan sirlucjan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❯ systemctl status scx                   
● scx.service - Start scx_scheduler
     Loaded: loaded (/usr/lib/systemd/system/scx.service; enabled; preset: disabled)
     Active: active (running) since Thu 2024-08-22 11:37:22 CEST; 1h 21min ago
 Invocation: 49cc28cb6fd34bc7b2ee344058f1331e
   Main PID: 54323 (scx_bpfland)
      Tasks: 2 (limit: 37769)
     Memory: 11.7M (peak: 18.9M)
        CPU: 369ms
     CGroup: /system.slice/scx.service
             └─54323 scx_bpfland --lowlatency

sie 22 12:58:39 cachyos bash[54323]: 10:58:39 [INFO] [scx_bpfland] tasks -> run:  4/4  int: 1  wait: 8    | nvcsw: 3    | dispatch -> dir: 11076920 prio: 8574830 shr: 63675
sie 22 12:58:40 cachyos bash[54323]: 10:58:40 [INFO] [scx_bpfland] tasks -> run:  2/4  int: 1  wait: 7    | nvcsw: 3    | dispatch -> dir: 11076920 prio: 8576487 shr: 67132
sie 22 12:58:41 cachyos bash[54323]: 10:58:41 [INFO] [scx_bpfland] tasks -> run:  4/4  int: 1  wait: 7    | nvcsw: 8    | dispatch -> dir: 11076920 prio: 8577757 shr: 70390
sie 22 12:58:42 cachyos bash[54323]: 10:58:42 [INFO] [scx_bpfland] tasks -> run:  4/4  int: 1  wait: 9    | nvcsw: 6    | dispatch -> dir: 11076920 prio: 8580116 shr: 73552
sie 22 12:58:43 cachyos bash[54323]: 10:58:43 [INFO] [scx_bpfland] tasks -> run:  3/4  int: 2  wait: 8    | nvcsw: 6    | dispatch -> dir: 11076920 prio: 8582535 shr: 76798
sie 22 12:58:44 cachyos bash[54323]: 10:58:44 [INFO] [scx_bpfland] tasks -> run:  4/4  int: 1  wait: 8    | nvcsw: 8    | dispatch -> dir: 11076920 prio: 8584137 shr: 79877
sie 22 12:58:45 cachyos bash[54323]: 10:58:45 [INFO] [scx_bpfland] tasks -> run:  4/4  int: 1  wait: 8    | nvcsw: 8    | dispatch -> dir: 11076920 prio: 8586224 shr: 83010
sie 22 12:58:46 cachyos bash[54323]: 10:58:46 [INFO] [scx_bpfland] tasks -> run:  3/4  int: 2  wait: 10   | nvcsw: 8    | dispatch -> dir: 11076920 prio: 8587724 shr: 86406
sie 22 12:58:47 cachyos bash[54323]: 10:58:47 [INFO] [scx_bpfland] tasks -> run:  4/4  int: 1  wait: 8    | nvcsw: 3    | dispatch -> dir: 11076920 prio: 8589042 shr: 89807
sie 22 12:58:48 cachyos bash[54323]: 10:58:48 [INFO] [scx_bpfland] tasks -> run:  3/4  int: 1  wait: 7    | nvcsw: 4    | dispatch -> dir: 11076920 prio: 8590517 shr: 92993

I have been using for a few days, everything works without regression.

Tested-by: Piotr Gorski ([email protected])

Introduce the new `--lowlatency` option, which enables switching between
the default pure vruntime-based scheduling (more optimized for server
workloads) and a deadline-based scheduling (better suited for
low-latency workloads).

When the low-latency mode is activated, a task's deadline is calculated
as its vruntime, adjusted by a bonus proportional to the task's average
number of voluntary context switches (the more voluntary context
switches, the shorter the deadline).

This feature enhances the prioritization of interactive tasks even more,
proportionally to their average voluntary context switches, also within
the two main global queues (priority / shared) and it helps to maintain
interactive workloads always responsive, even in presence of heavy
non-interactive background work.

Low-latency mode allows to prevent audio cracking even in presence of a
large amount of short-lived tasks with pseudo-interactive behavior (i.e,
hackbench) and it enables achieving approximately a +33% average
frames-per-second (FPS) in the typical "gaming while building the
kernel" benchmark.

However, it can also amplify the de-prioritization of CPU-intensive
tasks, making this option more suitable for specific low-latency
scenarios. Therefore the low-latency mode is disabled by default and it
can only be enabled via the `--lowlatency` option.

Tested-by: Piotr Gorski ([email protected])
Signed-off-by: Andrea Righi <[email protected]>
@arighi
Copy link
Contributor Author

arighi commented Aug 22, 2024

@sirlucjan thanks, added your tested-by line.

@arighi arighi merged commit 115bfc8 into main Aug 23, 2024
2 checks passed
@arighi arighi deleted the bpfland-lowlatency-mode branch August 23, 2024 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants