#linux-kernel #scheduler #bpf #scheduling #thread #userspace #policy

app scx_rustland

A BPF component (dispatcher) that implements the low level sched-ext functionalities and a user-space counterpart (scheduler), written in Rust, that implements the actual scheduling policy. This is used within sched_ext, which is a Linux kernel feature which enables implementing kernel thread schedulers in BPF and dynamically loading them. https://github.com/sched-ext/scx/tree/main

12 releases (6 stable)

1.0.6 Nov 6, 2024
1.0.4 Sep 7, 2024
1.0.1 Jul 15, 2024
0.0.7 Jun 3, 2024
0.0.1 Dec 22, 2023

#824 in Unix APIs

Download history 81/week @ 2024-08-03 17/week @ 2024-08-10 137/week @ 2024-08-17 11/week @ 2024-08-24 163/week @ 2024-09-07 50/week @ 2024-09-14 9/week @ 2024-09-21 195/week @ 2024-09-28 25/week @ 2024-10-05 12/week @ 2024-10-12 103/week @ 2024-11-02 19/week @ 2024-11-09

122 downloads per month

GPL-2.0-only

30KB
447 lines

scx_rustland

This is a single user-defined scheduler used within sched_ext, which is a Linux kernel feature which enables implementing kernel thread schedulers in BPF and dynamically loading them. Read more about sched_ext.

Overview

scx_rustland is made of a BPF component (scx_rustland_core) that implements the low level sched-ext functionalities and a user-space counterpart (scheduler), written in Rust, that implements the actual scheduling policy.

How To Install

Available as a Rust crate: cargo add scx_rustland

Typical Use Case

scx_rustland is designed to prioritize interactive workloads over background CPU-intensive workloads. For this reason the typical use case of this scheduler involves low-latency interactive applications, such as gaming, video conferencing and live streaming.

scx_rustland is also designed to be an "easy to read" template that can be used by any developer to quickly experiment more complex scheduling policies fully implemented in Rust.

Production Ready?

Not quite. For production scenarios, other schedulers are likely to exhibit better performance, as offloading all scheduling decisions to user-space comes with a certain cost.

However, a scheduler entirely implemented in user-space holds the potential for seamless integration with sophisticated libraries, tracing tools, external services (e.g., AI), etc.

Hence, there might be situations where the benefits outweigh the overhead, justifying the use of this scheduler in a production environment.

Demo

scx_rustland-terraria

The key takeaway of this demo is to demonstrate that , despite the overhead of running a scheduler in user-space, we can still obtain interesting results and, in this particular case, even outperform the default Linux scheduler (EEVDF) in terms of application responsiveness (fps), while a CPU intensive workload (parallel kernel build) is running in the background.

Dependencies

~54MB
~675K SLoC