LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   Why Debian is not using swap as it should, and computer gets really slow when RAM is full or almost full? (https://www.linuxquestions.org/questions/debian-26/why-debian-is-not-using-swap-as-it-should-and-computer-gets-really-slow-when-ram-is-full-or-almost-full-4175723824/)

dedec0 04-06-2023 07:45 AM

Why Debian is not using swap as it should, and computer gets really slow when RAM is full or almost full?
 
Hello, people,

I have Debian installed in 2 computers. One has 15,5GiB of RAM, and a smaller disk, so i made a swap partition of "only" 15,9GiB. The problematic one has a bigger disk, but a fairly small RAM of only 3,8GiB; but i gave it a much bigger swap partition of 59,6GiB.

And the problematic one has an SSD disk, so, for the common uses i do with it, it should not be noticeable. But today, browsers usually grow a lot in memory, as i use them: open and close tabs, of several sites, with videos, images, and all complex things a site can have. This happens in both computers. In the first one, with more RAM, when RAM is full, and swap also is almost full, i close and reopen a few programs. This will make a lot of memory be freed - and the one with the biggest memory usage is always the browser.

But the problematic computer gets reeeeeeeeeeeeally really slow with a lot of swap still being free!

This issue has existed for several months, i just have not taken the time to ask about it here. I tried to search the web for this problem, and possible solutions, but found no good result with my searches.

I imagine some configuration of Debian, or the kernel, or whatever thing i know very little or nothing about.

Can you help me here?

camorri 04-06-2023 08:31 AM

Have a look at your swappieness setting. See this link for guidance.

-->https://linuxize.com/post/how-to-cha...alue-in-linux/

Use the free command to display free memory and free swap space. Keep in mind you can always add a swap file to swap space.

dedec0 04-06-2023 10:43 AM

Quote:

Originally Posted by camorri (Post 6422756)
Have a look at your swappieness setting. See this link for guidance.

-->https://linuxize.com/post/how-to-cha...alue-in-linux/

Use the free command to display free memory and free swap space. Keep in mind you can always add a swap file to swap space.

Both computers have the same values for everything - except, obvious, the sizes and used numbers. Given what is written in the link you sent, should i try a higher value in /proc/sys/vm/swappiness for in the problem computer? But why its behaviour is so different than the other, since the memory usage is grown with the exact same kind of actions, in the majority of them: browsing several sites?

camorri 04-06-2023 01:15 PM

Yes, higher number for swappieness. That makes the system swap more aggresifly. Other things to consider, is the web browser you are using. Some are know to fill up more ram. It can be related to the specific release of a browser as well.

What is the free command telling you on the 2 systems?

craigevil 04-06-2023 02:28 PM

You might want to give zram a try.
https://docs.kernel.org/admin-guide/blockdev/zram.html
https://wiki.archlinux.org/title/Zram
https://pimylifeup.com/raspberry-pi-zram/

Works great on my pi400.
Code:

*free
              total        used        free      shared  buff/cache  available
Mem:            3793        2330        347        319        1619        1463
Swap:          4095        322        3773
Total:          7889        2652        4121


dedec0 04-06-2023 02:54 PM

Quote:

Originally Posted by camorri (Post 6422815)
Yes, higher number for swappieness. That makes the system swap more aggresifly. Other things to consider, is the web browser you are using. Some are know to fill up more ram. It can be related to the specific release of a browser as well.

What i find strange is a behaviour so different, but with the same settings. Making the computer really slow, while there is a lot of swap available, does not make sense to me. I had such slowness in the good computer only when i did not care about the swap being practically full; it ended locking the computer, and i needed to manually reset it (in the hardware, i mean).


Quote:

Originally Posted by camorri (Post 6422815)
What is the free command telling you on the 2 systems?

Code:

$ free -h # This is the good behaviouring computer
              total        used        free      shared  buff/cache  available
Mem.:          15Gi      9,1Gi      2,1Gi      1,9Gi      4,3Gi      4,5Gi
Swap:          15Gi          0B        15Gi

$ free -h # This is the bad behaviouring computer
              total        used        free      shared  buff/cache  available
Mem.:          3,8Gi      3,0Gi      175Mi      223Mi      583Mi      284Mi
Swap:          59Gi      4,2GiB        55Gi

I just changed the swappiness using 2 things:


# First, I executed the command:
$ sysctl vm.swappiness=80

# To make the above change permanent, I also edited the file:
/etc/sysctl.conf

# adding the line below to it:
vm.swappiness=80

# And i used another command that was in the page sent above,
# and now its output is 80, reflecting the change of the
# command just made:
$ cat /proc/sys/vm/swappiness
80


The browser i prefer is Vivaldi. But i have heard that any current browser will end up using a lot of RAM, if it stays openned for a lot of hours (which is always the case when i restart it to free memory). Vivaldi is based on Chromium, as other browsers i would like to use {except "chorume (meanings 1, 4 or 5)"}, which i will never use.

Is there a browser with minimal memory usage, which can discard everything without needing to close+reopen it?

camorri 04-06-2023 04:07 PM

You going to have to experiment with different browsers. Keep an eye on the with free on the system that fails.

It is possible there is another issue we are not aware of. How much free space do you have on your root partition? Insufficient space can cause problems like you describe.

dedec0 04-06-2023 07:38 PM

Quote:

Originally Posted by camorri (Post 6422849)
You going to have to experiment with different browsers. Keep an eye on the with free on the system that fails.

It is possible there is another issue we are not aware of. How much free space do you have on your root partition? Insufficient space can cause problems like you describe.

My "eye with free" is on, practically all the time, because i use the system monitor that Mate Desktop has available to put in its UI (the same that Gnome 2 had, since Mate is built to continue that project). I keep it checking: processor, memory, swap, network, system load (right expression, in english?), and disk, in both computers.

The root partitions have a lot of space in both computers: 13GiB¹ in the good computer. And 216GiB¹ in the one with the problem here.

¹→ Is df -h output correct, as International System of Units/Sistema Internacional de Unidades, ou S.I., (in portuguese) says? The free -h command already is.

syg00 04-07-2023 01:20 AM

Let's see these.
Code:

grep -e "."  /proc/sys/vm/over*
grep -e "^Comm" /proc/meminfo


fatmac 04-07-2023 03:30 AM

I'm guessing that it may be something to do with systemd, I use Devuan myself, & I don't get any such problems running Firefox-esr on my machines that only have 4GB ram & no swap space....

(Devuan is a systemd free version of Debian....& I'm not here to bash systemd, just suggesting that it might have something to do with the problem at hand).

syg00 04-07-2023 03:56 AM

What a ridiculous suggestion - on zero evidence. Maybe it's the network manager, or the text editor in use.

:sheesh:

fatmac 04-07-2023 06:39 AM

Quote:

Originally Posted by syg00 (Post 6422940)
......on zero evidence. Maybe it's the network manager, or the text editor in use.

You could be right, it might be one of them....although highly unlikely to be a text editor!!! :rolleyes:

His system has the problem - mine doesn't! :hattip:

craigevil 04-07-2023 10:41 AM

Take a look at https://wiki.archlinux.org/title/Imp...torage_devices
https://wiki.archlinux.org/title/swap

I have this in /etc/sysctl.conf :
Code:

# Manual settings - these settings are to optimize for SSD drive
# Ref: https://wiki.archlinux.org/index.php/Solid_State_Drives
vm.swappiness=100
vm.vfs_cache_pressure=50
vm.dirty_background_ratio=1
vm.dirty_ratio=50

Brave browser frees up memory in unused tabs.

And /etc/fstab
Code:

proc            /proc          proc    defaults          0      0
PARTUUID=b4b590be-01  /boot          vfat    defaults          0      2
PARTUUID=b4b590be-02  /              ext4    defaults,noatime  0      1
# a swapfile is not a swap partition, no line here
#  use  dphys-swapfile swap[on|off]  for that
tmpfs        /tmp        tmpfs        defaults,noatime,mode=1777                0      0
#tmpfs        /var/tmp        tmpfs        defaults,noatime,mode=1777        0        0
#tmpfs        /var/log        tmpfs        defaults,noatime,mode=0755        0        0
#tmpfs        /var/spool        tmpfs        defaults,noatime,mode=1777        0        0


dedec0 04-07-2023 07:38 PM

Quote:

Originally Posted by syg00 (Post 6422915)
Let's see these.
Code:

grep -e "."  /proc/sys/vm/over*
grep -e "^Comm" /proc/meminfo


I did these 2 in both computers:


# Good computer

$ grep -e "." /proc/sys/vm/over*
/proc/sys/vm/overcommit_kbytes:0
/proc/sys/vm/overcommit_memory:0
/proc/sys/vm/overcommit_ratio:50

$ grep -e "^Comm" /proc/meminfo
meminfo

$ grep -e "^Comm" /proc/meminfo
meminfo

$ grep -e "^Comm" /proc/meminfo
CommitLimit: 24831676 kB
Committed_AS: 27777048 kB

$

# Bad computer, which is in a fairly slow situation, right
# now. I am not using it much, today, so, we can test it
# in some things that need this happening (if they exist).

$ grep -e "." /proc/sys/vm/over*
/proc/sys/vm/overcommit_kbytes:0
/proc/sys/vm/overcommit_memory:0
/proc/sys/vm/overcommit_ratio:50

$ grep -e "^Comm" /proc/meminfo
CommitLimit: 64473816 kB
Committed_AS: 11112736 kB

$


Meaningful?

dedec0 04-07-2023 07:43 PM

Quote:

Originally Posted by fatmac (Post 6422934)
I'm guessing that it may be something to do with systemd, I use Devuan myself, & I don't get any such problems running Firefox-esr on my machines that only have 4B ram & no swap space....

(Devuan is a systemd free version of Debian....& I'm not here to bash systemd, just suggesting that it might have something to do with the problem at hand).

Did you mean "that only have 4M ram"? 4B is four bytes, and this make no sense.


All times are GMT -5. The time now is 07:05 PM.