4 ms·
I wonder why we talk so often about swap but rarely about using zram. I mean, isn't it much simpler to add some zram as swap instead of messing with the partiti
by arendtio 7y ago
I wonder why we talk so often about swap but rarely about using zram. I mean, isn't it much simpler to add some zram as swap instead of messing with the partitions and in the end, it should solve the problem equally well, doesn't it?
I have seen this being done on Android devices and wondered why it is being used so rarely in other areas (Desktops/Servers).
- dredmorbius 7y agoSwap dates to the 1960s. zram was introduced to the mainline Linux kernel in 2014.[1] zswap presumably later, though Wikipedia states it was added in 2013, possibly indicating improved temporal performance under zswap.[2] Hrm, actually, they appear to be two distinct features. There's a lot of institutional knowledge, and mythology, around swap. Less so around zram/zswap, and that is going to compete with other competing capabilities and lore. I've been wranging boxen since the late 1990s, and using Unix since at least the late 1980s. I'd only run across references to zswap / zram a few weeks ago when attempting to compile OpenWRT, and didn't look into it until seeing your comment (one reason for writing copiously footnoted HN comments -- I might accidentally learn something). zswap might very well be The Answer We've All Been Looking for, but, well, All Of Us Realising that is another stage in the Hierarchy of Failures in Problem Resolution.[3] ________________________________ Notes: 1. https://en.m.wikipedia.org/wiki/Zram https://en.m.wikipedia.org/wiki/Zram 2. https://en.m.wikipedia.org/wiki/Zswap https://en.m.wikipedia.org/wiki/Zswap 3. https://old.reddit.com/r/dredmorbius/comments/2fsr0g/hierarchy_of_failures_in_problem_resolution/ https://old.reddit.com/r/dredmorbius/comments/2fsr0g/hierarc...
- zzzcpan 7y agoZswap is still backed by disk, it's better than a raw swap of course, but disk is still a problem. I fallback to zswap only if I can't use zram on a system.
- mrob 7y agoUsing zram swap in a recent Debian is as simple as installing "zram-tools" (and changing the size in /etc/default/zramswap if you're not happy with the default).
- dredmorbius 7y ago... and knowing to do that. And knowing to do that over other methods. Institutional knowledge, mindshare, and documentation are all Things. Debian's documentation (Debian Administrator's Handbook, Debian Installation Guide, Debian FAQ) do not appear to mention either zram or zswap at all. DAH/DIG do mention swap configuration, but only in terms of traditional swap patterns. There is mention on the Debian Wiki: https://wiki.debian.org/ZRam https://wiki.debian.org/ZRam But not under the Swap topic: https://wiki.debian.org/Swap https://wiki.debian.org/Swap "As easy as" really doesn't mean much if the information isn't accessible. It's also harder to to advocate if it's not at least mentioned in standard documentation. If you're aware of any standard Linux documentation mentioning zram/zswap as options, please let me know. Again: this is not an argument against the technical merits or advisibility of zram or zswap. It's an argument that knowledge of these options is not widely disseminated or assimilated. I'd commented recently on the matter of intergenerational knowledge transfer, both general and specific (https://news.ycombinator.com/item?id=20617656 https://news.ycombinator.com/item?id=20617656). This would be a case of that.
- arendtio 7y agoThanks for the info. For everybody, who wants to use it with Arch Linux, the following link should give a good overview: https://wiki.archlinux.org/index.php/Improving_performance#Zram_or_zswap https://wiki.archlinux.org/index.php/Improving_performance#Z... If you want to use the systemd solution you can do it like: pacman -S systemd-swap vim /etc/systemd/swap.conf # disable zswap, enable zram systemctl start systemd-swap.service systemctl enable systemd-swap.service
- zzzcpan 7y agoAnd you probably can't even find an environment these days where swap on disk works better than swap on zram, people are just unaware that it exists and how it performs. You can squeeze so much out of zram, it's ridiculous. I'm thinking of dropping freebsd systems that I have just because of how much more I can fit on a system with zram and freebsd doesn't have it.
- markjdb 7y agoWe are hoping have something similar in the next freebsd release, FWIW.
- CoolGuySteve 7y agoYeah, a small bit of zram with alerts or automated scaling when it starts to fill up seems like the right answer here. zram and zswap are also a lifesaver on low memory devices like chromebooks, especially if they have anything slower than nvme storage.