On Saturday, June 6, 2020 1:15:35 AM MST Samuel Sieb wrote:
On 6/6/20 12:42 AM, John M. Harris Jr wrote:
> On my laptop, a Lenovo X200T with Core(TM)2 Duo CPU U9300; 6 GiB RAM,
> enabling swap on zram led to increased CPU usage (Always above 13% where
> normally idling at 6%!), and my entire system freezing after about 30
> minutes. In all fairness, I don't know why my system froze, as I couldn't
> get anything over netconsole and sysrq wasn't working, but I think I'm
> going to leave it disabled. Swap on disk is more than fast enough for
> buffer/cache and hibernation/resume on my system.
I don't know why you had problems with it, but it's working on fine on
every system I've tried it on. It's not increasing my CPU usage. It's
probably actually lower due to less swap thrashing.
There wasn't any thrashing to begin with. I'm currently using 8.0Mi of my 8
GiB of swap. This is most likely the case for most casual users, those not
compiling complex software on their system. This is with Firefox,
Konversation, KMail, virt-manager and a few Konsole sessions open.
> I don't know why people seem to be repeating what seems to
be the result
> of a placebo, saying that their system "feels more responsive" with swap
> on zram. People seem to be forgetting why swap on zram came up to begin
> with, it has nothing to do with system "responsiveness", which wasn't
an
> issue. It had to do with dealing with OOM. Swap on zram isn't even a
> solution to that, it just changes how specifically it affects systems.
See, this is a clear indication that you don't understand what it is
doing and weren't listening to the various people trying to explain it.
It is definitely not a placebo. I gave zram 5G out of the 12G I have
and my laptop is performing way better now. It's not thrashing the disk
(SSD) every time I switch desktops or windows. Due to the number and
size of applications I'm running, I normally have to close Thunderbird
when I want to run Chrome. But now I can start Chrome up with no
problem. I converted my running system with no reboots and I didn't
change anything else about how I'm using the laptop.
# zramctl
NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lz4 5G 5G 1.7G 1.8G 4
5GB of swap space that normally would be on disk is now taking less than
2G of RAM. Instead of the usual 6G in the disk swap, now I have less
than 2.
> For servers, swap is useful regardless of the amount of RAM. Swap is very
> nice for use as buffer/cache, and leaves space in RAM for whatever the
> server is running. For example, I always configure a 4 GiB swap partition
> on servers with 8-24 GiB of RAM, and 8 GiB swap for servers with 64-128
> GiB, 16 GiB on servers with 128-256 GiB, etc. Beyond that, tuning is a
> bit different depending on the workload, but it sets a very nice starting
> point.
Swap is never used as buffer or cache, that doesn't even make sense.
Buffer is storing data before writing it to disk and cache is keeping
hot data somewhere with fast access. Why do you use so much swap on
your servers? The linear correlation with RAM is an obsolete idea and
was only somewhat valid when memory sizes were smaller. If you're using
any significant fraction of that swap space, your server is in trouble.
It's not used for kernel buffer/cache, that's correct.
--
John M. Harris, Jr.