by chronogram · 2y ago · 0 comments
This means there's a lot of available RAM capacity, that there's a hefty read cache to avoid the SD card, that when there are disk writes on writable storage it can still read from it, and with the lack of clustering and the speed of decompression there's no swapping lag whenever a page needs to be swapped back. This swap early, swap often is the complete opposite of the OOM-prevention swapping you used to use on disks, which was slow and interrupted IO whereas LZ4 in RAM is fast and doesn't interrupt IO.
I have been using this setup since 2022 and have not had any issues but I don't compile anything on those setups, though I see no reason why it would not be safer than compiling without zram at all.
/etc/sysctl.d/99-240716-vm.conf
vm.dirty_background_ratio = 1
vm.dirty_ratio = 100
vm.page-cluster = 0
vm.swappiness = 200
vm.vfs_cache_pressure = 1
dirty_background_ratio = starts background writing when it's at least 1% of available mem; dirty_ratio = starts force writing when all avail (not total) ram is full; page-cluster = swap in only what's needed; swappiness = lower means swapping is expensive higher signals swapping is cheap; vfs_cache_pressure = lower keeps more dentries and inodes in memory. /etc/udev/rules.d/99-240716-ioschedulers.rules
ACTION=="add|change", KERNEL=="mmcblk[0-9]*|nvme[0-9]*|sd[a-z]*", ATTR{queue/scheduler}="none"
Removes schedulers from typical local writeable storage. /etc/systemd/zram-generator.conf
[zram0]
zram-size = ram
compression-algorithm = lz4
Might have to install systemd-zram-generator if it doesn't already exist.