mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-11-10 09:43:30 +01:00
One of the nicest perks of using scx is the ability to easily switch between schedulers at run-time, but this is currently not possible in NixOS, given that the scx service only uses the scheduler from the config file. It's possible, however, to override the scheduler and its flags using the `SCX_SCHEDULER_OVERRIDE` and `SCX_FLAGS_OVERRIDE` environment variables, respectively (see [more details](https://en.opensuse.org/Pluggable_CPU_schedulers#Temporarily_switch_to_a_different_scheduler)). So the solution here is to change the scx service executable and pass those env vars to the service at run-time falling back to the values from the module config as defaults. After this change, it would be possible to override schedulers like so: ```shellSession $ sudo systemctl set-environment SCX_SCHEDULER_OVERRIDE='scx_lavd' $ sudo systemctl set-environment SCX_FLAGS_OVERRIDE='--performance' $ sudo systemctl restart scx.service ``` ```shellSession $ journalctl -u scx.service -b 0 -e Oct 18 13:09:25 nixos systemd[1]: Started SCX scheduler daemon. Oct 18 13:09:25 nixos bash[1829848]: 13:09:25 [INFO] Performance mode is enabled. Oct 18 13:09:25 nixos bash[1829848]: 13:09:25 [INFO] Energy model won't be used for CPU preference order. Oct 18 13:09:26 nixos bash[1829848]: 13:09:26 [WARN] libbpf: map 'lavd_ops': BPF map skeleton link is uninitialized Oct 18 13:09:26 nixos bash[1829848]: 13:09:26 [INFO] scx_lavd scheduler is initialized (build ID: 1.0.16 x86_64-unknown-linux-gnu) Oct 18 13:09:26 nixos bash[1829848]: 13:09:26 [INFO] scx_lavd scheduler starts running. ``` And also restore to the module defaults: ```shellSession $ sudo systemctl unset-environment SCX_SCHEDULER_OVERRIDE $ sudo systemctl unset-environment SCX_FLAGS_OVERRIDE $ sudo systemctl restart scx.service ``` ```shellSession $ journalctl -u scx.service -b 0 -e Oct 18 13:12:56 nixos systemd[1]: Stopped SCX scheduler daemon. Oct 18 13:12:56 nixos systemd[1]: Started SCX scheduler daemon. Oct 18 13:12:56 nixos bash[1833220]: 13:12:56 [INFO] NUMA nodes: 1 Oct 18 13:12:56 nixos bash[1833220]: 13:12:56 [INFO] Disabling NUMA optimizations Oct 18 13:12:56 nixos bash[1833220]: 13:12:56 [INFO] scx_bpfland 1.0.16 x86_64-unknown-linux-gnu SMT on ``` |
||
|---|---|---|
| .. | ||
| atd.nix | ||
| cron.nix | ||
| fcron.nix | ||
| prefect.nix | ||
| scx.nix | ||