linux desktop performance/experiments 

so @koz_ross recently mentioned his system locks up without linux-ck and i remembered that yeah, mine freezes up and gets stuttery when building stuff

is there a way to fix this with stock linux? introducing my two-part EXPERIMENT: launch everything with systemd-run, and set up systemd-oomd

there's going to be a lot of systemd stuff here so if you're not running systemd, this probably isn't for you

linux desktop performance/experiments 

the core issue here is resource starvation and the system not knowing which resources to prioritize

so how does linux scheduling work? muqss does this based on latency, but mainline uses the completely fair scheduler- each process gets a block of time proprtional to other processes

this will definitely let fork bombs and other massively parallel things kill your system

linux desktop performance/experiments 

so one way to fix this is by setting the nice levels of stuff. the main downside of this is that it's not automatic and it's still proportional

another way is using autogroups which groups processses- so you no longer schedule based on unix processes but on terminal session groups. seems saner and actually solves issues

but cgroups disables autogroups, yikes!
so what do we do?

linux desktop performance/experiments 

well if you run systemd-cgls you can see that most of your user programs are running in a single session cgroup (unless you're on a DE or something), meaning your firefox running youtube and your make tree are back at square one with all equal weight

so one solution to fix this is to run programs indirectly, such as 'systemd-run --user --scope PROGRAM'. this puts the PROGRAM and anything else it runs in its own cgroup!

linux desktop performance/experiments 

so i prefixed my keybindings in i3 for dmenu and startups with this, and now firefox and each terminal i open are in different cgroups. i had to use '--disable-server' for xfce4-terminal since some terminal emulators like to daemonize

nothing has changed in my workflow and i have a MUCH better system for latency as now i can run 'ninja -j32' in one terminal and not have any system stutters

linux desktop performance/experiments 

another issue linux hits is running out of memory. this can be a headache to solve for the kernel and things like earlyoom, but with cgroups it's simple- systemd will look for the cgroup using all the memory and kill it. so if i run 'ninja -j0' it will kill my terminal cgroup once it hits OOM and not touch anything else i'm doing

linux desktop performance/experiments 

another bonus is forkbombs: while writing this i ran a forkbomb and then killed the cgroup containing all the forkbomb shit

linux desktop performance/experiments 

it would be nice for linux to have a program for launching applications in linux like this, like 'launch' that would automatically set up cgroups and things, maybe even nice levels and processes- automatically according to some config

Follow

linux desktop performance/experiments 

@jookia I've tested this setup, but in Firefox, I get _really_ bad video stutter at high loads. I get audio stutter also, but that's much less if the video is not being displayed and I'm not loading a chonky website.

Sign in to participate in the conversation
Mastodon

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!