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/)

fatmac 04-08-2023 03:45 AM

Quote:

Originally Posted by dedec0 (Post 6423087)
Did you mean "that only have 4M ram"? 4B is four bytes, and this make no sense.

:lol: No, the 'G' didn't print, & I didn't notice, it should read 4GB, (now corrected).... ;)

business_kid 04-08-2023 07:57 AM

I've only 4G on my RazPi. I use a lightweight WM (XFCE) and it's generally ok. With Zoom under box64, a lot of libs are processed and held in ram, and I need 6G. Does your swap show in df -h? If not, it's not mounted, or might be puny. Here's how I made my swap file
  1. Pick some file or just touch one
  2. dd if=/dev/zero of=swapfile bs=100M count=2048
  3. mkswap swapfile
  4. swapon swapfile
Then enter it in /etc/fstab. htop is also good for memory stats.

dedec0 04-08-2023 08:04 AM

Quote:

Originally Posted by fatmac (Post 6423147)
:lol: No, the 'G' didn't print, & I didn't notice, it should read 4GB, (now corrected).... ;)

I see. So, it has a fairly good amount of memory. Probably the same as the computer with the problem here.

But you are (possibly) using the "bad unity" of measure, that conflicts with the International System of Units (ISU). See what i said in the #8 post, in this thread.

Since you are using something derived from Debian, i think you will have the same "details" in the free command. It is a bit offtopic for the thread, but i think it has its importance. Do a few commands to see, show us, and i show you my output here, in the good computer:



$ free -h # Use the shorter 3 digits unity closer to each value
total used free shared buff/cache available
Mem.: 15Gi 10Gi 2,1Gi 1,7Gi 3,0Gi 3,3Gi
Swap: 15Gi 717Mi 15Gi

$ free -b # Use bytes (B) unity for all values
total used free shared buff/cache available
Mem.: 16690577408 11274518528 2184806400 1822777344 3231252480 3547979776
Swap: 17082347520 751828992 16330518528

$ free --si # Use I.S.U. units
total used free shared buff/cache available
Mem.: 16299392 10915508 2215820 1792592 3168064 3547052
Swap: 16681980 734208 15947772

$



See the difference? If we use letters k, M, G, T, etc. to count computing related things, there is ambiguity. And companies use this "detail" to sell us less than we think. To buy, we receive a "16 gigabytes" (I. S. U. things) memory. But what it really has is actually "15,544 gigabytes" (1024 power), or correctly writing and saying: 15,544 GiB or 15,544 gibibytes (fifteen gibibytes and five hundred and fourty for thousandths ).

fatmac 04-09-2023 04:08 AM

Not sure what this will prove, but here they are, (I normally use free -m, so have included it also).

Code:

keith@msi:~$ free -m
              total        used        free      shared  buff/cache  available
Mem:            3730        1028        1524        265        1178        2194
Swap:            255          0        255
keith@msi:~$ free -h
              total        used        free      shared  buff/cache  available
Mem:          3.6Gi      1.0Gi      1.5Gi      265Mi      1.2Gi      2.1Gi
Swap:          255Mi          0B      255Mi
keith@msi:~$ free -b
              total        used        free      shared  buff/cache  available
Mem:      3912134656  1078628352  1597992960  278691840  1235513344  2300465152
Swap:      268431360          0  268431360
keith@msi:~$ free --si
              total        used        free      shared  buff/cache  available
Mem:        3820444    1068460    1545344      272160    1206640    2231420
Swap:        262140          0      262140

(This is with Firefox having been running for several hours.)

business_kid 04-09-2023 04:56 AM

So you're using 1 Gig of ram and have 1.5 Gig free besides caches and that's why there's no swap usage. Linux is very efficient with memory. Until I got box64, I never used swap on my RazPi.

The Pi is really slow - period. Arm have much better 64 bit cores than the A-72, but they must be overpriced, so everyone doing things on the cheap gets the A-53 or A-72. Firefox sucks also. Palemoon or Chromium are better.

273 04-09-2023 08:35 AM

All I'm reading here is that a computer with less RAM is becoming slower than one with more RAM once the swap starts to be used. Isn't that to be expected? Surely the one with less RAM has more of the current, in use, programs and data in swap so finds it slower to access those?
When I have experimented with filling RAM to see what happens (I have no swap) I find that once RAM is full the machine does not slow down it simply starts killing programs to free RAM for the "most important" so I don't think a lack of memory in and of itself causes slowness just the actual inability to use as much RAM.

business_kid 04-09-2023 09:33 AM

I use slarm64, not debian. Debian for Pi gets mixed reviews, and you don't get answers. Run 'df-h', 'sensors', and 'free -h' again when it's very slow and post results. Debian just don't care. It's not their distro.

Also run htop. You can see where memory & cpu are being used. If it's overheating, the Pi can slow drastically, and switch cores off, which affects performance.

If you want to try slarm64, there's a forum here under distributions and a RazPi 3&4 thread with links to the binary images. It's my choice of the Slackware Arm ports.

dedec0 04-09-2023 01:53 PM

Quote:

Originally Posted by fatmac (Post 6423362)
Not sure what this will prove, but here they are, (I normally use free -m, so have included it also).

Code:

keith@msi:~$ free -m
              total        used        free      shared  buff/cache  available
Mem:            3730        1028        1524        265        1178        2194
Swap:            255          0        255
keith@msi:~$ free -h
              total        used        free      shared  buff/cache  available
Mem:          3.6Gi      1.0Gi      1.5Gi      265Mi      1.2Gi      2.1Gi
Swap:          255Mi          0B      255Mi
keith@msi:~$ free -b
              total        used        free      shared  buff/cache  available
Mem:      3912134656  1078628352  1597992960  278691840  1235513344  2300465152
Swap:      268431360          0  268431360
keith@msi:~$ free --si
              total        used        free      shared  buff/cache  available
Mem:        3820444    1068460    1545344      272160    1206640    2231420
Swap:        262140          0      262140

(This is with Firefox having been running for several hours.)

And beyond what business_kid said, 'free' says that 1,2Gi are being used with buffer or cache. So, it says, in the last column of your output, you have 2,1Gi available. Is my interpretation of the free output correct, business_kid? (or anyone who wants to say this)

Now, about the comparison of using ISU or not, the difference (in absolute byte numbers) is bigger for bigger numbers. See this "table" with 3 columns and several lines:



Code:

IS unit                    1 B  = 1 byte
Wrong unit (should be)      1 B =      1 byte
Difference (using ISU)      0 B = 0 bytes

IS unit                    1 KiB = 1* 2^10 bytes = 1.024 bytes   
Wrong unit (should be)      1 kB = 1* 10^3 bytes       
Difference (using ISU)      +24            = 24        = 24

IS unit                    1 MiB = 1* 2^20 bytes = 1.048.576 bytes
Wrong unit (should be)      1 MB = 1* 10^6 bytes =  1.000.000 bytes
Difference (using ISU)      +48.576        = 49 KiB    = 49kB

IS unit                    1 GiB = 1* 2^30 bytes = 1.073.741.824 bytes
Wrong unit (should be)      1GB =  1* 10^9 bytes = 1.000.000.000 bytes
Difference (using ISU)      +73.741.824    = 73 MiB    = 73MB

IS unit                    1 TiB = 1* 2^40 bytes = 1.099.511.627.776 bytes
Wrong unit (should be)      1TB =  1* 10^12 =      1.000.000.000.000 bytes
Difference (using ISU)      +99.511.627.776 = 99 GiB    = 99GB



So, when we buy a disk with "1TB" of space, you may be thinking you are getting almost 100 GiB more than what it actually has!

And when you use the argument "-m" for free, you are always getting numbers being showed in MiB. They are in ISU mibibytes. So, the number of bytes of each number you see, should be obtained when you multiply it by 2^20 (which is 1 MiB). Is this clear?

dedec0 04-09-2023 01:57 PM

Quote:

Originally Posted by 273 (Post 6423389)
All I'm reading here is that a computer with less RAM is becoming slower than one with more RAM once the swap starts to be used. Isn't that to be expected? Surely the one with less RAM has more of the current, in use, programs and data in swap so finds it slower to access those?
When I have experimented with filling RAM to see what happens (I have no swap) I find that once RAM is full the machine does not slow down it simply starts killing programs to free RAM for the "most important" so I don't think a lack of memory in and of itself causes slowness just the actual inability to use as much RAM.

No. Not expected to the point it is happening here. No program was ever killed (the browser keeps running, ever for days, as i have tried a few of the first times this happened; and it would be the first one that would be killed, i think). And its disk is not so slow.

273 04-09-2023 02:00 PM

Quote:

Originally Posted by dedec0 (Post 6423442)
No. Not expected to the point it is happening here. No program was ever killed (the browser keeps running, ever for days, as i have tried a few of the first times this happened; and it would be the first one that would be killed, i think). And its disk is not so slow.

But using swap is slow - remember that unless you're not using that disk for anything but swap it's also being used by other processes and that the speed of swap is levels of magnitude slower than RAM.
The fact you're not seeing processes being killed means you're not exhausting your swap and RAM, and the system is behaving as it should, it's just the swap you are using is slowing your system.

dedec0 04-09-2023 02:00 PM

Quote:

Originally Posted by business_kid (Post 6423398)
I use slarm64, not debian. Debian for Pi gets mixed reviews, and you don't get answers. Run 'df-h', 'sensors', and 'free -h' again when it's very slow and post results. Debian just don't care. It's not their distro.

Also run htop. You can see where memory & cpu are being used. If it's overheating, the Pi can slow drastically, and switch cores off, which affects performance.

If you want to try slarm64, there's a forum here under distributions and a RazPi 3&4 thread with links to the binary images. It's my choice of the Slackware Arm ports.

You are not saying this to my problem, right? But the other situation cited above, for comparison, correct?

dedec0 04-09-2023 02:20 PM

Quote:

Originally Posted by 273 (Post 6423443)
But using swap is slow - remember that unless you're not using that disk for anything but swap it's also being used by other processes and that the speed of swap is levels of magnitude slower than RAM.
The fact you're not seeing processes being killed means you're not exhausting your swap and RAM, and the system is behaving as it should, it's just the swap you are using is slowing your system.

No. It does not make sense. During the slowness periods, there is no other process making much use of RAM or disk or swap - if any, since they are so little. And the slowness is a lot stronger than I have seen years ago when (for example) using a computer with 32MiB of RAM run a game that recommends 512MiB or more. 4GiB of RAM, today, is something common. The hardware of the computer good i have been calling good is probably worse than the other.

My "disk of bad" here has a lot of free space (around 213GiB). The swap is huge (64GiB, and it is never used, i barely see it in the system monitor graph, seen all the time), so the system should (probably should, this is a guess, a thought of mine) not worry to split data to store into smaller pieces, to fit into fragmented space, or moving data to make free space have bigger continuous areas.

273 04-09-2023 02:25 PM

Quote:

Originally Posted by dedec0 (Post 6423446)
No. It does not make sense. During the slowness periods, there is no other process making much use of RAM or disk or swap - if any, since they are so little. And the slowness is a lot stronger than I have seen years ago when (for example) using a computer with 32MiB of RAM run a game that recommends 512MiB or more. 4GiB of RAM, today, is something common. The hardware of the computer good i have been calling good is probably worse than the other.

My "disk of bad" here has a lot of free space (around 213GiB). The swap is huge (64GiB, and it is never used, i barely see it in the system monitor graph, seen all the time), so the system should (probably should, this is a guess, a thought of mine) not worry to split data to store into smaller pieces, to fit into fragmented space, or moving data to make free space have bigger continuous areas.

OK, so if swap isn't the problem a way way to confirm this is to turn off swap and make full use of the RAM and see whether it slows then. If it doesn't slow in that case then it is something to do with swap and if it doesn't then it's not.

business_kid 04-10-2023 07:41 AM

I'm seeing posts here which is crazy. @decdec0, the dictionary is the only place you see 'success' come before 'work.'

sure windows slows. Magazines write about windows, but we're fixing a linux problem. Linux is very well designed. I had a chance to obseve my 3.7G being overloaded. It filled up to 3.4-3.5G, and then started filling swap. I'll bet you're not using swap.

It could be: Chips overheating; dodgy disk partitions; a kernel problem; a very slow network; library incompatabilities, to name just a few. You won't try anything, so how do we know? Check those areas out. Don't waffle but give us information in short diagnostic posts.

dedec0 04-11-2023 05:02 PM

Quote:

Originally Posted by business_kid (Post 6423541)
I'm seeing posts here which is crazy. @decdec0, the dictionary is the only place you see 'success' come before 'work.'

sure windows slows. Magazines write about windows, but we're fixing a linux problem. Linux is very well designed. I had a chance to obseve my 3.7G being overloaded. It filled up to 3.4-3.5G, and then started filling swap. I'll bet you're not using swap.

It could be: Chips overheating; dodgy disk partitions; a kernel problem; a very slow network; library incompatabilities, to name just a few. You won't try anything, so how do we know? Check those areas out. Don't waffle but give us information in short diagnostic posts.

Right. Thank you for this list.

I will try this starting list, for now. I have already checked how to disable swap, I will just prepare a few details to avoid losing anything, in the case of the system killing running programs.

A problem of very slow network should not be the problem, I think. The network for these 2 computers is the same: both connected with a cable to the same modem (and it receives data with a coaxial cable, from the network company). I would see the slowness in the other computer, I think.


All times are GMT -5. The time now is 09:31 AM.