You are not logged in.

#1 2020-05-19 07:00:59

Snaporaz
Member
From: Switzerland
Registered: 2020-03-23
Posts: 11

Swappiness not working

I've recently installed Arch and I've noticed that my system freezes many times.
My problem is that the RAM (16GB) reaches 100% and then I can't do much more than to manually reboot.

In some cases, this has been solved by installing earlyoom, but it still happens that everything freezes with the memory explosion being the fault of a single process.

if I check my swappiness I get
    cat /proc/sys/vm/swappiness : 60

However, the swap is never used before the RAM usage reaches >95%

I'm now wondering if this is due to the fact that I did full disk encryption and then created a swap file, instead of creating a non-encypted partition for the swap.
Although an unencrypted swap doesn't make much sense to me.

Is there any chance that this is a downside of encryption?
if not, where do I need to look to start and fix it?

Offline

#2 2020-05-19 07:06:50

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,672

Re: Swappiness not working

Swap is not free RAM, you don't want it used unless absolutely necessary (and from the description we have so far, this seems to work as intended). What process "explodes" in RAM usage so that you go to 100% in the first place?

Last edited by V1del (2020-05-19 07:15:57)

Offline

#3 2020-05-19 07:17:26

seth
Member
Registered: 2012-09-03
Posts: 51,056

Re: Swappiness not working

This is not what swappiness does, https://bbs.archlinux.org/viewtopic.php?id=231265

There're several posts that suggest that LVM rather than encryption causes a massive CPU overhead.
Also, since swap is only used for anon pages, it matters how exactly the faulty process allocates the memory.

Finally, you're tackling the wrong problem: No matter how you configure it, if a single process allocates enourmous amounts of memory (in a very short time), your system performace will go south.
The problem is that process which you want to address by either fixing or sidestepping the issue or putting a RAM quota on the process (so it can only ever get a fixed amount of RAM and will crash if it wants more) - eg. using ulimit or cgroups.

Edit: fuck.

Last edited by seth (2020-05-19 07:17:48)

Offline

#4 2020-05-19 07:20:27

Snaporaz
Member
From: Switzerland
Registered: 2020-03-23
Posts: 11

Re: Swappiness not working

V1del wrote:

Swap is not free RAM, you don't want it used unless absolutely necessary (and from the description we have so far, this seems to work as intended). What process "explodes" in RAM usage so that you go to 100% in the first place?

I know. I'm not trying to do that.
I'm working on a project that sometimes will require a lot of RAM depending on what I'm testing and many times I won't be able to tell beforehand.

Now if it's going to use, let's say, 12GB I don't want to have to manually kill everything else on my laptop just because It can't swap (or be killed), forcing me to reboot.
I'm not looking at having it as fast as possible after the code/test/debug part I will move to a remote machine for the actual runs but for the moment I'm stuck with my laptop.

Before I was doing the same but with Ubuntu and I had that whenever the precess was requiring too much RAM it will be killed and then I'll now that I had to test something simpler.

Last edited by Snaporaz (2020-05-19 07:43:56)

Offline

#5 2020-05-19 07:43:24

Snaporaz
Member
From: Switzerland
Registered: 2020-03-23
Posts: 11

Re: Swappiness not working

seth wrote:

This is not what swappiness does, https://bbs.archlinux.org/viewtopic.php?id=231265

There're several posts that suggest that LVM rather than encryption causes a massive CPU overhead.
Also, since swap is only used for anon pages, it matters how exactly the faulty process allocates the memory.

Finally, you're tackling the wrong problem: No matter how you configure it, if a single process allocates enourmous amounts of memory (in a very short time), your system performace will go south.
The problem is that process which you want to address by either fixing or sidestepping the issue or putting a RAM quota on the process (so it can only ever get a fixed amount of RAM and will crash if it wants more) - eg. using ulimit or cgroups.

Edit: fuck.

This was extremely instructive.

I still have a small question. I'm still puzzled about why earlyoom is not taking care of it.
I also have to admit that if the system stays frozen for more then 5min I'm not going to give it any more time, and I read in the thread that you posted that there were people that had to wait 30min.



By looking at my settings for earlyoom:

-> % earlyoom 
earlyoom 1.6
mem total: 15890 MiB, swap total: 16383 MiB
sending SIGTERM when mem <= 10.00% and swap <= 10.00%,
        SIGKILL when mem <=  5.00% and swap <=  5.00%

I guess that the problem is that it needs to fill too much swap before kicking in and at that point, everything is already slow as f.

Last edited by Snaporaz (2020-05-19 07:55:38)

Offline

#6 2020-05-19 08:22:06

ugjka
Member
From: Latvia
Registered: 2014-04-01
Posts: 1,806
Website

Re: Swappiness not working

I set limits on user processes and system processes with cgroups and systemd

Enable DefaultMemoryAccounting=yes in /etc/systemd/system.conf

and

[ugjka@archee ~]$ systemctl set-property user.slice MemoryMax=80%
[ugjka@archee ~]$ systemctl set-property system.slice MemoryMax=10%

Adjust percentages accordingly to your liking. You wanna leave some empty space for caches so don't use up all 100% combined

You can go wild with cgroups and even set limits on individual processes/systemd units

Last edited by ugjka (2020-05-19 08:33:53)


https://ugjka.net
paru > yay | webcord > discord
pacman -S spotify-launcher
mount /dev/disk/by-...

Offline

Board footer

Powered by FluxBB