3

I currently have most of my swap on Zram, since I don't want to wear my SSD excessively.

BUT, I do have a swap partition left over from when the system was installed, and I just lowered the priority of this, and enabled it as well...

My question is this:-

  1. Can I enable Zswap, to provide it's writeback cache function for my SSD based swap, without it trying to cache the Zram based swap?...

  2. What exactly does the priority do, I assume it's just a matter of "fill X before Y", but is it possible to have long term stuff stored in one swap area and more transient stuff stored in another... say Zram for transient, with longer term stuff stored on SSD.

  3. Is there any way to see which swaps have Zswap active?

I understand the implications (and apparent illogic) of swapping to RAM, this is a question regarding what criteria zswap uses to determine if it should cache a device, or not... and how it plays with swap on zram.

Note: I have enough ram to run without swap 99% of the time, but it's normal for initialisation code and perhaps the odd memory leak accumulate and this would be swapped out if it could be.... so zram swap will half the usage of this compared to having no swap and it has almost no overhead otherwise. Also, I support a large number of Linux systems, many of which cannot have disk based swap... so I want to know if zswap and zram play nice together, so that I know if this is something I /can/ do if the situation warrants it, or not.

By "Play Nice", I mean... zswap should cache "disk/ssd" based swap, but no zram based swap!

James Lewis
  • 971
  • 7
  • 7
  • 1
    SSD wear due to swap is a non-issue on late model SSDs. zram/zswap only takes away resources from what you probably already don't have enough of... RAM. Edit your question and show me `free -h` and `swapon -s` and `sysctl vm.swappiness` and `cat /etc/fstab` and `sudo fdisk -l` and I'll take a look for you. – heynnema Jun 05 '21 at 16:38
  • The issue with swapping on SSD's has seriously impacted Apple M1 users due to relatively small RAM, and swapping on soldered SSD wearing them out.... I would argue that more recent domestic SSD's are using DLC and QLC cells, that still have under 1000 rewrite cycles.... so zswap and zram do have value. – James Lewis Jun 06 '21 at 15:08
  • Are you using a M1? 8G RAM? Is the SSD soldered in? – heynnema Jun 06 '21 at 15:16
  • No, but that's besides the point. for example, take one system I have been looking at recently which has 128GB RAM, and 8GB swap on SAS disk. The host is busy, and while it always has 40+GB free, the swap is always full with rarely accessed stuff. The user has complained that occasionally their application blocks for 1-2 seconds during swapping. Replace 8GB of disk based swap with 12GB zram swap, and after 3:1 compression the actual saving in physical ram is 8GB in both cases.... but zram is very much faster. Linux always seems to run better with /some/ swap, regardless if it has free RAM. – James Lewis Jun 07 '21 at 13:32
  • I appreciate the fact that you are trying to help, but please understand that I am looking for information on how zswap interacts with swap on zram... rather than commentary on any specific situation. They both appear to have desirable, and potentially complimentary functionality, but I'm concerned about negative interaction between the two. – James Lewis Jun 07 '21 at 13:38
  • For your 128G RAM example, I would have checked the vm.swappiness value, and set it to 10 – heynnema Jun 07 '21 at 13:39
  • I appreciate that swappiness can be tuned to adjust how much memory pressure is required to trigger things being swapped out, but in this, and many other cases swapping things out that aren't used for long periods is desirable.... as these systems have large datasets so increasing the disk cache by 8-10GB will reduce the load on the SAN storage considerably, and swap has about a 9:1 radio write to read, which means that about 90% of what is swapped out is never read back in (pages freed)... – James Lewis Jun 07 '21 at 13:52

0 Answers0