4

Running Ubuntu 12.10 here, on an 128Gb SSD and a 4GB RAM system. Ever since I installed the OS, I realised that I dont need the swap partition, as I never use the hibernate function and rarely run out of RAM. However, would installing zRam bring any real improvement when RAM is full, even if there is no swap partition?

  • Using zRAM On Ubuntu 13.04 Linux phoronix.com/scan.php?page=news_item&px=MTM1NjQ – Qasim May 21 '13 at 1:44
  • I'm running 16.10 with 8GB ram and still found zram made everything more 'peppy'. I have a 10 year old laptop with 1.5GB RAM and it seems to me that the more the RAM, the more effective zram is. – Christopher Nov 10 '16 at 21:55
9

I would presume whether or not you have swap space is more or less irrelevant to the usefulness of zRam. Regardless of whether or not you have zRam installed, if you run out of RAM with no swap space, bad things start to happen. :-)

If you do expect to run out of RAM, then zRAM could be helpful because it essentially expands the amount of data you can store in RAM (assuming it's not of unreasonably high entropy) so it will take longer to fill up. So it might buy you some more time, assuming you're not storing large arrays of random numbers.

If you're 99.9% sure you won't get close to running out of RAM (i.e. you have 16GB on your web-only netbook), than anything stored in zRAM is needlessly requiring extra CPU time to compress and decompress, so it's not really beneficial in this case.

If you're on the high end of the RAM usage spectrum (on average over 50-60%, for example) you might benefit from some additional peace of mind using zRAM. (Or you could buy more RAM.)

I suppose you have to evaluate your normal and heavily-loaded RAM utilization (average and max) and what kind of data you work with.

3

Yes enabling zRAM is certainly a best thing.why means zRAM will creates a RAM based block device which acts as a swap disk, but is compressed and stored in memory instead of swap disk allowing very fast I/O and increasing the amount of memory available before the system starts swapping to disk.

Actually compcache is the original name and its changed to zRAM these days.

you can install it with sudo apt-get install zram-config

2

zRAM will only get used if it's needed, so enabling it will have no effect if you don't need it. I very much doubt you will even notice it working when it is needed.

1

It is NOT true that disabling swap is bad. Because if you running out of memory without swap OOM will be invoked and some of tasks just die, you can continue your work. In case with swap it's very easy to run out of memory + out of swap, in this case your machine will hang in disk IO. Most probably reasons you run out of memory (memory leak, huge allocation) - it wouldn't stop on RAM size, it will eat whole swap too and you will run out of memory anyway.

You could easily try this with simple program which allocates memory in infinity loop with and without swap.

-2

I'd say that if Linux kernel did work perfectly, using zRam and no real swap would be probably pointless unless you know for a fact that the RAM contents will compress really well and you're a bit short on RAM.

However, I'm running system with 32 GiB of RAM, zero real swap and I've installed zram-config but modified /etc/init/zram-config.conf to use only 5% of RAM for zram (instead of default 50%). This allows kernel to see some swap but that swap is hugely faster than any SDD. As a result, all swap-related codepaths inside kernel can be used and I think this has fixed some issues that I had when I didn't have swap at all. (Namely, it seems to me that when RAM is fragmented and the system does not have any swap, the kernel is not clever enough to workaround the problem. However, with zRam or swap on ramdisk, the kernel is able to move pages to swap and relocate during swapin. That's only my theory, though.)

TL;DR: zRam in a system without real swap space allows kernel to use all swap related codepaths which may avoid some bugs.

  • Whoever downvoted this answer should explain his or her vote. If you feel that the answer is incorrect, please point out the error or fix the answer if you have enough reputation. – Mikko Rantalainen Jan 14 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.