4 ms·
> Or when you're swapping memory back in for an app/page that's scattered among many 4 KB pages on disk... but the point is that should still be faster than rel
by codedokode 4y ago
> Or when you're swapping memory back in for an app/page that's scattered among many 4 KB pages on disk... but the point is that should still be faster than reloading the page over the internet!
I don't think so. HDD can do approximately 100 IOPS, and with 4kB pages that gives you speed of 400Kb/s.
I had different cases when system worked poorly when there was not enough RAM. All of these happened to me on 4Gb Linux system:
- when a heavy page is opened in Firefox and it tries to allocate more than 500 Mb of RAM (for example, Google Street View that leaks RAM), the system swaps out Gnome desktop compsitor, and everything freezes for several minutes, you cannot even move a mouse or switch to a text console. Often the only solution is reboot. Why cannot Linux protect Wayland compositor from being swapped out I don't understand.
- when the system turns off the screen, it can swap out desktop compositor because it is not used, and there is a freeze for 20-30 seconds when you try to wake up the system. Why cannot it swap out something less important I don't understand.
So in practice swapping can produce long freezes when the system becomes completely unresponsive. I cannot agree with your statement that getting a page from swap is faster than loading from Internet.
If instead of swapping separate pages the system swapped out and in whole processes, the situation might be better.
By the way, out of curiosity I tried to investigate who uses so much memory that 4Gb becomes not enough by summing PSS (proportional set size) of processes, and I never got 4Gb used, it always was about 2.6-2.8 Gb used after which the system becomes prone to sudden freezes. "free" command also never showed number of "used" RAM above 3Gb. I guess Linux has not only issues with swapping, but also with counting used memory as well.
- crazygringo 4y agoThe long freezes you describe come from thrashing, when memory is at its limit. Forget about background apps/tabs, you simply don't have enough memory period. Swapping doesn't perform miracles. And I was clear I wasn't talking about severely underprovisioned machines, such as you are describing. In normal usage where background apps/tabs are swapped out preemptively, there is no performance hit at all. And then when they're reloaded from swap -- yes, it's extremely fast. It's like loading a web page from your local drive, only even faster because it doesn't have to be interpreted. If you're dealing with freezes of 20 seconds to several minutes, your machine is severely underpowered or somehow seriously misconfigured. You need to upgrade, not complain about how swap doesn't work.