A framework for building custom Linux schedulers using BPF and Go.
Current status: not ready for production use.
This scheduler is designed to prioritize interactive workloads over background CPU-intensive tasks. It's particularly suitable for:
- Low-latency interactive applications
- Gaming
- Video conferencing
- Live streaming
The scheduler consists of two main components:
- A BPF component that implements low-level sched-ext functionalities
- A user-space scheduler written in Go with scx_goland_core that implements the actual scheduling policy
- Virtual runtime (vruntime) based scheduling
- Latency-sensitive task prioritization
- Dynamic time slice adjustment
- CPU topology aware task placement
- Automatic idle CPU selection
The scheduling policy is based on virtual runtime:
- Each task receives a time slice of execution (slice_ns)
- The actual execution time is adjusted based on task's static priority (weight)
- Tasks are dispatched from lowest to highest vruntime
- Latency-sensitive tasks receive priority boost based on voluntary context switches
Prerequisites:
- Go 1.22+
- LLVM/Clang 17+
- libbpf
- Linux kernel 6.12+ with sched_ext support
First, clone the required dependencies:
make dep
git submodule init
git submodule sync
git submodule update
cd scx
meson setup build --prefix ~
meson compile -C build
This will clone libbpf and the custom libbpfgo fork needed for the project.
Build the scheduler with:
make build
This compiles the BPF program, builds libbpf, generates the skeleton, and builds the Go application.
To test the scheduler in a virtual environment using kernel v6.12.2:
make test
This uses vng
(virtual kernel playground) to run the scheduler with the appropriate kernel version.
To run the scheduler on your system:
sudo ./main
The scheduler will run until terminated with Ctrl+C (SIGINT) or SIGTERM.
If you need to inspect the BPF components, you can use:
sudo bpftool prog list # List loaded BPF programs
sudo bpftool map list # List BPF maps
sudo cat /sys/kernel/debug/tracing/trace_pipe # View BPF trace output
stress-ng -c 20 --timeout 20s --metrics-brief
This software is distributed under the terms of the GNU General Public License version 2.
Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.