topic title: zramfs for swap
Posts: 69
Ninho
Joined: 28 Oct 2016
#1
Opening new thread per SamK's gracious suggestion:
Sam, you wrote you have been using a compressed memory swapfile on a
laptop with as little as 384 MB memory. While i understand the argument
about belating the use of swap to hard disk - and associated thrashing -
yet it would seem disadvantageous, having already a small total of RAM,
to reduce the size available for processes even more. In addition,
the operation of zram compression/decompression would be taxing
a slow CPU, hence reducing the performance overall, wouldn't it ?
I might as well do so expermineting of my own...
How many kilobytes had you allocated for that zram'd swap area, please ?
Posts: 1,028
SamK
Joined: 21 Aug 2011
#2
Ninho wrote:...it would seem disadvantageous, having already a small total of RAM,
to reduce the size available for processes even more. In addition,
the operation of zram compression/decompression would be taxing
a slow CPU, hence reducing the performance overall, wouldn't it ?
These are reasonable questions that are I have seen asked by others when first thinking of using zram. You went on to answer your own questions when you went on to say
Ninho wrote:I might as well do so expermineting of my own...
In the end it is the only way you will reach a decision.
Ninho wrote:...it would seem disadvantageous, having already a small total of RAM,
to reduce the size available for processes even more.
Presumably your view extends to the use of compressed files like zip or tgz or 7z files using up some disk space that could be used for other files or even allocating a swap partition means there is less overall disk space available.
Ninho wrote:In addition,
the operation of zram compression/decompression would be taxing
a slow CPU, hence reducing the performance overall...
This is understandable speculation. Try it for yourself then decide. I have never noticed the effect you describe even on the least powerful kit.

Re-read the original linked post post46641.html#p46641
its basic thrust is about ways to optimise performance on ancient kit. Often such kit has a low spec. Trying to use that kit in the same way you might use modern high spec kit is a fruitless exercise. So if you intend to use zram to achieve that be prepared for a disappointment. The post covers a range of ideas, any one of which may not produce a big gain. The right combination of them (which might include the use of zram) is much more likely to produce worthwhile results. One of the ways to obtain the most noticeable improvements is to choose appropriate apps and use them in a sensible way. If you want to use any form of swap space to compensate for a lack of physical RAM in old kit in order to employ demanding modern apps you are again likely to be disappointed. You will get much more performance from your old system by slightly modifying the way you perform your daily tasks and using other lightweight apps to do them. By giving up a small amount of convenience it is possible to obtain large gains.

On old resource limited kit, trying to view zram in isolation is not helpful. It is more beneficial to look at it in the context of your overall system which in essence means the capability of your hardware, the apps you intend to use, and the way you use them.

I'm not advocating in favour or against the use of zram. It is your system and in the end you will make your own choice. When building a system I use guidelines and a form of flowchart for swap space that I prepared some years back. I never published them because swap space is one of those contentious areas where people tend to aggressively defend their own preferences. All I will say is they have served me well and whenever I use zram (often in conjunction with a disk based swap space) I am happy with the outcome.
Posts: 69
Ninho
Joined: 28 Oct 2016
#3
Well, thanks for sharing your reasoned thoughts - though you haven't answered re: how much for a start you allocated to the virtual-memory-in-zRAM from 384 MBytes total ? -
Still not convinced there could be any circumstances to make such an arrangement beneficial, but let's agree to disagree here ;=)
The other suggestions and general philosophy of your posts in thread very much appreciated and agreed with !
Posts: 1,028
SamK
Joined: 21 Aug 2011
#4
Ninho wrote:Still not convinced there could be any circumstances to make such an arrangement beneficial...
That's OK, as I said previously I'm not trying to convince you or anyone else, though your comment has a tang of having done little before making such an observation.

A few thoughts off-the-top-of-my-head
  • It seems unlikely that zram would be merged into the Linux kernel if there was no benefit to it
  • Running in RAM is inherently faster than running from disk; that includes swap
  • Using antiX in live nomadic mode on modern highly spec'd kit that you do not administrate and therby cannot be certain a disk based swap area is available or accessible
  • Potentially extending the life of a USB stick running antiX in live mode when a swap space is wanted on the stick
Some quotes from
========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"https://en.wikipedia.org/wiki/Zram"
linktext was:"https://en.wikipedia.org/wiki/Zram"
====================================
wikipedia wrote: zram was merged into the Linux kernel mainline in kernel version 3.14...
[...]
Since using zram is an alternative way to provide swapping on RAM, zram allows Linux to make a better use of RAM when swapping/paging is required, especially on older computers with less RAM installed.
[...]
Google uses zram in Chrome OS since 2013[7] and in Android since its version 4.4.[8] Lubuntu also started using zram in its version 13.10.[9] As of December 2012,[needs update?] Ubuntu has considered enabling zram by default on computers with small amounts of installed RAM