@natty Can I interest you in zswap in these trying times?
@benaryorg The poor thing is already slow :(

I believe in Node.js not crashing through the limit
@natty zram is actually really fast, also it reduces memory pressure significantly if it's able to swap out something meaning your system will spend significantly less time with paging, so it's actually worth it.
@benaryorg Yeah, but if the CPUs are busy cruching stuff and I introduce memory compression, will it actually outweigh the negatives?
@natty You can always set the vm.swappiness to a lower value to make it swap out as little as possible, but the kernel has really good heuristics based on which it will swap out, so even with swappiness of 90 it will only really write out data that it's worth swapping.
@benaryorg Oh cool, I was actually wondering about memory compression the other day, now I know the answer

@natty It's not anything magic that hooks into memory management and does some compression or anything, it's really "just" a memory backed sparse block device that also compresses the data, which is then used as regular swap, so the regular swapping mechanism applies.

You could even enable it at runtime to test it.

modprobe zram
tee /sys/class/block/zram0/comp_algorithm <<<zstd
tee /sys/class/block/zram0/disksize <<<5Gi
mkswap /dev/zram0
swapon /dev/zram0

(all commands work with a regular sudo prefix too if you don't feel like opening a root shell)

@natty And if you check /proc/pressure/memory (i.e. cat the file) you'll see how much load is generated from memory pressure. The avg values tell you approximately how much CPU time the kernel is wasting by doing memory stuff (paging magic).

Edit: the total value is an absolute value in microseconds wasted, so if you have monitoring that can do diffs, it's enough to pull that one (it's what node exporter does for instance), you can then calculate the per-second value from that and if it approaches 1 million you're spending 100% of the CPU on paging, if it's at 100k you're spending 10% of the CPU on paging.

@natty Plus with zstd as the algorithm it achieves around 1:5 compression ratio on my box, so it's basically free ram at that point.