Re: FIREFOX is killing the whole PC Part III
On 23.11.2022 17:09, Schwibinger Michael wrote:
> Good afternoon
>
> I saw cgroups.
>
> Thank You.
>
> But I cant understand.
>
> Is it a concept to limit all tasks?
You can limit all, a single one or (the name suggests this one) a group of processes. There are plenty of system resources which can be configured.
> Where can I find a introduction?
I don't know either. But maybe this one is fine to start with:
https://www.redhat.com/sysadmin/cgroups-part-one
Some examples limiting Firefox to 500 MB of RAM and low CPU resources, do as root:
####
# cd into the cgroup filesystem, defaults to cgroup2 on Debian Bullseye, others may vary
cd /sys/fs/cgroup/
# create a new cgroup
mkdir ffox
# cd into the cgroup dir
cd ffox/
# add all firefox-esr processes to the cgroup, all newly created subprocesses will automatically get added to ffox cgroup
for i in $(pidof firefox-esr); do echo $i > cgroup.procs ; done
# limit memory usage to 500 MB
echo 500M > memory.high
# limit cpu usage to less wight (defaults to 100)
echo 10 > cpu.weight
# also limit swap memory because else it will fill swap after the memory limit kicks in
echo 100M > memory.swap.max
####
... now watch Firefox stall if other processes either use CPU resources or Firefox tries to consume more than 600 MB of Memory (which is small nowadays for multiple tabs; but mind, if Firefox already has more memory allocated it will keep this).
Typically you can use some more friendly userspace interface. But don't think of using cgroup-tools with Debian Bullseye: Version 0.41 in Bullseyes repository supports cgroups V1 only while Bullseyes Kernel defaults to V2.
There's plenty of help you can find with your favourite Internet search engine.
regards
hede
PS: to remove Firefox from the ffox cgroup either restart Firefox or:
cd /sys/fs/cgroup/ffox/ && for i in $(cat cgroup.procs); do echo $i > ../cgroup.procs ; done
Reply to: