
A few days after upgrading the last of my machines from Fedora 32 to 33, I noticed my main machine has acquired a new disk: NAME SIZE FSTYPE LABEL MOUNTPOINT zram0 4G [SWAP] I didn't set that up, and I don't think it was there on F32. So the OS has, without asking, co-opted 1/4 of my 16G of RAM to use as swap space. This system has an SSD, so when I initially set it up (Fedora 27), I made a conscious decision to go without swap space. I rarely push the limits of 16G. But now I'm in the situation that I have only 12G of RAM, so the system will become memory-starved earlier ... and what will it do? It will go to swap. Which is RAM anyway. How does this help? To me this seems like adding complexity without adding utility. Can someone please explain A) if I'm correct about this behaviour in the first place, and B) why it's useful? Thanks. -- Giles https://www.gilesorr.com/ gilesorr@gmail.com

| From: Giles Orr via talk <talk@gtalug.org> | I didn't set that up, and I don't think it was there on F32. So the | OS has, without asking, co-opted 1/4 of my 16G of RAM to use as swap | space. This system has an SSD, so when I initially set it up (Fedora | 27), I made a conscious decision to go without swap space. I rarely | push the limits of 16G. [I'm aware of zswap but haven't looked into it. I'm too pressed for time to do the proper research. So I'll hypothesize, using common sense.] This doesn't surprise me. Except for the "without asking" part. I hypothesize that you got this with a fresh install where you opted for the installer to decide on partitioning. If you tell it how to partition, I hope it would not give you zswap without your direction. The zswap is compressed. So things moved there take less RAM than they would without swapping. (I hope that it notices when things are incompressable and hence would save no space.) I have no idea whether it is truly pre-allocated RAM or it is just a limit and that the actual RAM tied up reflects usage. I would hope that it shrinks and grows as needed. It may be that, in terms of RAM, this is a pure win. In terms of CPU, this is another matter. | Can someone please explain | A) if I'm correct about this behaviour in the first place, and Check the F33 Release Notes? (I have not.) I've certainly seeen discussion about ZSwap. Unfortunately, I've mostly ignored it. Other distros have it too. I don't know whether they automatically configure it on installation. | B) why it's useful? Thanks. See above. - for sure, some running processes are almost never actual run. ZSwap is a win for those. Unless latency maters. - I assume that when zswap fills up, old-fashioned disk swap is used. In this case, zswap is a win over having only swap. You could think of zswap as a kind of cache or intermediate stage for disk swap.

I have a lot of experience running Linux on IBM mainframes, and using RAM as swap is a good thing, we do that all the time on our mainframes. And even if it sounds strange, it decreases latency by A LOT. We call it VDISK (virtual disk). Usually we use a VDISK only as an indicator that the guest needs more RAM, so as soon as any virtual machine uses the VDISK, we are notified and take a look at it to see if some process is using more memory than it should, or there is real need for more RAM. Imagine you fire up Firefox, open a new tab, and there's no RAM available. Linux will have to swap something, write pages to disk (with the very slow disk IO compared to RAM), and after that allocate more memory to Firefox, that was suspended all this time. If you do this to RAM instead, it is way faster. And zswap has a process for offloading pages from zswap to disk, so it really is a cache for swap. So it's useful. Mauro https://www.maurosouza.com - registered Linux User: 294521 Scripture is both history, and a love letter from God. Em qua., 25 de nov. de 2020 às 11:35, D. Hugh Redelmeier via talk < talk@gtalug.org> escreveu:
| From: Giles Orr via talk <talk@gtalug.org>
| I didn't set that up, and I don't think it was there on F32. So the | OS has, without asking, co-opted 1/4 of my 16G of RAM to use as swap | space. This system has an SSD, so when I initially set it up (Fedora | 27), I made a conscious decision to go without swap space. I rarely | push the limits of 16G.
[I'm aware of zswap but haven't looked into it. I'm too pressed for time to do the proper research. So I'll hypothesize, using common sense.]
This doesn't surprise me. Except for the "without asking" part.
I hypothesize that you got this with a fresh install where you opted for the installer to decide on partitioning. If you tell it how to partition, I hope it would not give you zswap without your direction.
The zswap is compressed. So things moved there take less RAM than they would without swapping. (I hope that it notices when things are incompressable and hence would save no space.)
I have no idea whether it is truly pre-allocated RAM or it is just a limit and that the actual RAM tied up reflects usage. I would hope that it shrinks and grows as needed.
It may be that, in terms of RAM, this is a pure win. In terms of CPU, this is another matter.
| Can someone please explain | A) if I'm correct about this behaviour in the first place, and
Check the F33 Release Notes? (I have not.)
I've certainly seeen discussion about ZSwap. Unfortunately, I've mostly ignored it. Other distros have it too. I don't know whether they automatically configure it on installation.
| B) why it's useful? Thanks.
See above.
- for sure, some running processes are almost never actual run. ZSwap is a win for those. Unless latency maters.
- I assume that when zswap fills up, old-fashioned disk swap is used. In this case, zswap is a win over having only swap.
You could think of zswap as a kind of cache or intermediate stage for disk swap. --- Post to this mailing list talk@gtalug.org Unsubscribe from this mailing list https://gtalug.org/mailman/listinfo/talk

TIL: https://fedoraproject.org/wiki/Changes/SwapOnZRAM ( last edit oct 2020 ) When I first read this I thought: if you are swapping it's _becasue_ you ran out of ram, so why "swap" to ram? TL:DR; it compresses the data. also: NOT preallocated. David On Wed, Nov 25, 2020 at 8:18 AM Giles Orr via talk <talk@gtalug.org> wrote:
A few days after upgrading the last of my machines from Fedora 32 to 33, I noticed my main machine has acquired a new disk:
NAME SIZE FSTYPE LABEL MOUNTPOINT zram0 4G [SWAP]
I didn't set that up, and I don't think it was there on F32. So the OS has, without asking, co-opted 1/4 of my 16G of RAM to use as swap space. This system has an SSD, so when I initially set it up (Fedora 27), I made a conscious decision to go without swap space. I rarely push the limits of 16G.
But now I'm in the situation that I have only 12G of RAM, so the system will become memory-starved earlier ... and what will it do? It will go to swap. Which is RAM anyway. How does this help? To me this seems like adding complexity without adding utility.
Can someone please explain A) if I'm correct about this behaviour in the first place, and B) why it's useful? Thanks.
-- Giles https://www.gilesorr.com/ gilesorr@gmail.com --- Post to this mailing list talk@gtalug.org Unsubscribe from this mailing list https://gtalug.org/mailman/listinfo/talk
-- David Thornton https://wiki.quadratic.net https://github.com/drthornt/ https://twitter.com/northdot9/

On Wed, 25 Nov 2020 at 08:18, Giles Orr <gilesorr@gmail.com> wrote:
A few days after upgrading the last of my machines from Fedora 32 to 33, I noticed my main machine has acquired a new disk:
NAME SIZE FSTYPE LABEL MOUNTPOINT zram0 4G [SWAP]
I didn't set that up, and I don't think it was there on F32. So the OS has, without asking, co-opted 1/4 of my 16G of RAM to use as swap space. This system has an SSD, so when I initially set it up (Fedora 27), I made a conscious decision to go without swap space. I rarely push the limits of 16G.
But now I'm in the situation that I have only 12G of RAM, so the system will become memory-starved earlier ... and what will it do? It will go to swap. Which is RAM anyway. How does this help? To me this seems like adding complexity without adding utility.
Can someone please explain A) if I'm correct about this behaviour in the first place, and B) why it's useful? Thanks.
Hugh, this machine was an upgrade from Fedora 32. I guess the decision was made to go with the new default rather than ask questions during the upgrade. Thanks Hugh, Mauro, Dave for the info - and my apologies, I did zero research before turning to the list. Not my usual behaviour, I promise - I guess I was peeved because it was so unexpected. I assumed right out the gate that the statement "4G" meant it was using 4G of RAM. As has been pointed out, it's not allocated until it's used, and it's compressed - so even when full it'll usually only use 2G of RAM. After having read about it some, it sounds like it's mostly a win. -- Giles https://www.gilesorr.com/ gilesorr@gmail.com
participants (4)
-
D. Hugh Redelmeier
-
David Thornton
-
Giles Orr
-
Mauro Souza