The size is allright, but the zswap config is crucial.
I can't figure out how to do it in guix with any certainty, perhaps you can enable it manually once to test and then research it better if you feel that it's worth it. Like this, as root:
In regular swap, when you're low on memory the kernel chooses some memory pages (low priority processes and least recently used) and writes them on disk on a file or partition. When the process that owns those pages need them back, the kernel goes fetch them one at a time. Since memory pages are 4KiB the speed on this depends on the 4k random access speed of your disk.
You can have more than one swap, and the order they are used depends on their priority, or on the order they were enabled in if you didn't specify any priority.
zram is a kind of swap space that, instead of writing to disk, compresses the pages and writes them back in RAM. You set an uncompressed size for it and if the pages don't compress well (usually encrypted on already-compressed data) then it will occupy the same amount of RAM. Since you can't tell in advance what the compressed size will be and there's no mechanism to stop it from filling up, you must be conservative on the size of zram. When the zram gets full all new pages will go to the next swap in priority order. This causes a problem where there's old data you don't care about taking RAM space in zram that cannot be reclaimed, and then your workload is going to regular swap which is slow.
zswap is a layer on top of swap, the technical name is "frontswap". For it to work you need to already have a swap configured. Before memory pages are written down on the swap file, they are compressed, and if the compression ratio is good enough the pages go to RAM instead of to the swap file. You set a compressed size for the zswap (by default, 20% of your total RAM) and when this limit gets full the least recently used pages are written to disk. The compression is so fast that you barely notice a hiccup while it's happening, it feels like you magically have 50% more RAM than before.
Answering your question, zswap is configured by kernel parameters, and now that you mention it it might work to put the parameters on the kernel cmdline instead of editing sysfs, this means configuring the boot loader and adding zswap.enabled=1 zswap.compressor=lz4 zswap.zpool=z3fold to the kernel cmdline.
The size is allright, but the zswap config is crucial.
I can't figure out how to do it in guix with any certainty, perhaps you can enable it manually once to test and then research it better if you feel that it's worth it. Like this, as root:
The
1 > enabled
must be written after the other two. If you don't have sysfs mounted at /sys, check with themount
command where it is.A couple of mailing list threads that may help you do it "properly" in guix:
https://lists.gnu.org/archive/html/guix-devel/2023-02/msg00077.html https://lists.gnu.org/archive/html/guix-devel/2018-03/msg00332.html
deleted by creator
Yes, more or less, they are closely related:
In regular swap, when you're low on memory the kernel chooses some memory pages (low priority processes and least recently used) and writes them on disk on a file or partition. When the process that owns those pages need them back, the kernel goes fetch them one at a time. Since memory pages are 4KiB the speed on this depends on the 4k random access speed of your disk.
You can have more than one swap, and the order they are used depends on their priority, or on the order they were enabled in if you didn't specify any priority.
zram is a kind of swap space that, instead of writing to disk, compresses the pages and writes them back in RAM. You set an uncompressed size for it and if the pages don't compress well (usually encrypted on already-compressed data) then it will occupy the same amount of RAM. Since you can't tell in advance what the compressed size will be and there's no mechanism to stop it from filling up, you must be conservative on the size of zram. When the zram gets full all new pages will go to the next swap in priority order. This causes a problem where there's old data you don't care about taking RAM space in zram that cannot be reclaimed, and then your workload is going to regular swap which is slow.
zswap is a layer on top of swap, the technical name is "frontswap". For it to work you need to already have a swap configured. Before memory pages are written down on the swap file, they are compressed, and if the compression ratio is good enough the pages go to RAM instead of to the swap file. You set a compressed size for the zswap (by default, 20% of your total RAM) and when this limit gets full the least recently used pages are written to disk. The compression is so fast that you barely notice a hiccup while it's happening, it feels like you magically have 50% more RAM than before.
Answering your question, zswap is configured by kernel parameters, and now that you mention it it might work to put the parameters on the kernel cmdline instead of editing sysfs, this means configuring the boot loader and adding
zswap.enabled=1 zswap.compressor=lz4 zswap.zpool=z3fold
to the kernel cmdline.deleted by creator
Huh, when I set it up
zsmalloc
wasn't finished and never deallocated. But it seems that today it's the right choice! Thanks.