Crates.io | scx_chaos |
lib.rs | scx_chaos |
version | 1.0.19 |
created_at | 2025-04-22 15:43:14.649719+00 |
updated_at | 2025-09-05 23:18:38.232505+00 |
description | scx_chaos A general purpose sched_ext scheduler designed to amplify race conditions |
homepage | |
repository | |
max_upload_size | |
id | 1644255 |
size | 1,091,429 |
A general purpose sched_ext
scheduler designed to amplify race conditions for testing and debugging.
scx_chaos
is a specialized scheduler that intentionally introduces various forms of latency and performance degradation to help expose race conditions and timing-dependent bugs in applications. Unlike traditional schedulers that aim for optimal performance, scx_chaos
is designed to stress-test applications by introducing controlled chaos into the scheduling process.
WARNING: This scheduler is experimental and should not be used in production environments. It is specifically designed to degrade performance and may cause system instability.
The scheduler supports several "chaos traits" that can be enabled individually or in combination, with more to come:
Run without chaos features (baseline performance):
sudo scx_chaos
sudo scx_chaos --random-delay-frequency 0.1 --random-delay-min-us 100 --random-delay-max-us 1000
sudo scx_chaos --cpufreq-frequency 0.2 --cpufreq-min 400000 --cpufreq-max 2000000
sudo scx_chaos --degradation-frequency 0.15 --degradation-frac7 64
sudo scx_chaos --kprobes-for-random-delays schedule do_exit --kprobe-random-delay-frequency 0.05 --kprobe-random-delay-min-us 50 --kprobe-random-delay-max-us 500
Run a specific command under the chaos scheduler:
sudo scx_chaos [chaos-options] -- ./your-application --app-args
The scheduler will automatically detach when the application exits.
Focus chaos on a specific process and its children:
sudo scx_chaos --pid 1234 [chaos-options]
Enable statistics monitoring:
sudo scx_chaos --stats 1.0 [chaos-options] # Update every 1 second
Run in monitoring mode only (no scheduler):
sudo scx_chaos --monitor 2.0
Automatically restart applications for continuous testing:
# Restart on failure
sudo scx_chaos --repeat-failure [chaos-options] -- ./test-app
# Restart on success
sudo scx_chaos --repeat-success [chaos-options] -- ./test-app
Note: For the most up-to-date and complete CLI documentation, run
scx_chaos --help
. This includes all chaos-specific options as well as the full set of p2dq performance tuning options.
--random-delay-frequency <FLOAT>
: Probability of applying random delays (0.0-1.0)--random-delay-min-us <MICROSECONDS>
: Minimum delay time--random-delay-max-us <MICROSECONDS>
: Maximum delay time--cpufreq-frequency <FLOAT>
: Probability of applying frequency scaling--cpufreq-min <FREQ>
: Minimum CPU frequency--cpufreq-max <FREQ>
: Maximum CPU frequency--degradation-frequency <FLOAT>
: Probability of applying degradation--degradation-frac7 <0-128>
: Degradation fraction (7-bit scale)--kprobes-for-random-delays <FUNCTION_NAMES>
: Kernel functions to probe--kprobe-random-delay-frequency <FLOAT>
: Probability of kprobe delays--kprobe-random-delay-min-us <MICROSECONDS>
: Minimum kprobe delay--kprobe-random-delay-max-us <MICROSECONDS>
: Maximum kprobe delay--verbose
, -v
: Increase verbosity (can be repeated)--stats <SECONDS>
: Enable statistics with update interval--monitor <SECONDS>
: Run in monitoring mode only--ppid-targeting
: Focus on target process and children (default: true)--repeat-failure
: Restart application on failure--repeat-success
: Restart application on success--pid <PID>
: Monitor specific process ID--version
: Print version and exitsched_ext
and kprobe operations)sched_ext
support, chaos has very limited backward compatibilityThe scheduler provides various statistics including:
scx_chaos
is built on the sched_ext
framework and uses the scx_p2dq
scheduler as its base. It implements chaos traits through BPF programs that intercept scheduling decisions and apply configured disruptions based on probability distributions.