Prevent Desktop GUI from sluttering under high load
The scheduler is responsible for keeping the CPUs in the system busy. The Linux scheduler implements a number of scheduling policies, which determine when and for how long a thread runs on a particular CPU core - Source.
The default CPU Scheduler in Linux is CFS, which gives every process a fair share of processor time. Which is exactly what we don't want in a Desktop. A Background CPU eater process shouldn't get a fair share of processor time while compromising the GUI responsiveness.
Switch to a CPU Scheduler specifically designed for desktop use cases. scx_lavd is one such CPU Scheduler, which is very easy to set up as well, thanks to SCX.
- Install scx for your Distribution.
- sudo nano /etc/default/scx to configure SCX_SCHEDULER=scx_lavd
- sudo systemctl enable --now scx.service
Test it yourself? Hammer your CPU while playing a YouTube video in the background in Firefox, Open Webgl acquarium in another tab.
stress-ng --cpu 0Now watch the CPU utilization in your favourite System Monitor software or top, while Firefox and your Desktop Environment is fairly responsive.
Difficult to setup than SCX, at least in openSUSE. Maybe it is readily available with a custom kernel in your distro in the form of linux-zen or something?
Set up ZSWAP while keeping swappiness (60) and vfs_cache_pressure at the default settings.