#linux-kernel #userspace #scheduler #bpf #hybrid #thread #user-defined

app scx_rusty

A multi-domain, BPF / user space hybrid scheduler 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

15 releases (7 stable)

1.0.6 Nov 6, 2024
1.0.4 Sep 7, 2024
1.0.1 Jul 15, 2024
0.5.7 Jun 3, 2024
0.5.0 Nov 30, 2023

#420 in Unix APIs

Download history 95/week @ 2024-08-05 10/week @ 2024-08-12 150/week @ 2024-08-19 148/week @ 2024-09-02 22/week @ 2024-09-09 59/week @ 2024-09-16 5/week @ 2024-09-23 215/week @ 2024-09-30 20/week @ 2024-10-07 5/week @ 2024-10-14 115/week @ 2024-11-04 8/week @ 2024-11-11

123 downloads per month

GPL-2.0-only

145KB
3K SLoC

Rust 2K SLoC // 0.1% comments C 1.5K SLoC // 0.2% comments

scx_rusty

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

A multi-domain, BPF / user space hybrid scheduler. The BPF portion of the scheduler does a simple round robin in each domain, and the user space portion (written in Rust) calculates the load factor of each domain, and informs BPF of how tasks should be load balanced accordingly.

How To Install

Available as a Rust crate: cargo add scx_rusty

Typical Use Case

Rusty is designed to be flexible, accommodating different architectures and workloads. Various load balancing thresholds (e.g. greediness, frequency, etc), as well as how Rusty should partition the system into scheduling domains, can be tuned to achieve the optimal configuration for any given system or workload.

Production Ready?

Yes. If tuned correctly, rusty should be performant across various CPU architectures and workloads. By default, rusty creates a separate scheduling domain per-LLC, so its default configuration may be performant as well. Note however that scx_rusty does not yet disambiguate between LLCs in different NUMA nodes, so it may perform better on multi-CCX machines where all the LLCs share the same socket, as opposed to multi-socket machines.

Note as well that you may run into an issue with infeasible weights, where a task with a very high weight may cause the scheduler to incorrectly leave cores idle because it thinks they're necessary to accommodate the compute for a single task. This can also happen in CFS, and should soon be addressed for scx_rusty.

Dependencies

~34–46MB
~673K SLoC