On 01/10/2023 09:31, gene heskett wrote:
Fedora has it by default since a while, and at first I thought it's a very stupid idea. In practise, I can't be bothered anymore to create these annoying swap partitions. They're only a waste of disc space. There haven't been any issues with it, and when the machine runs out of memory, using swap partitions or swap files isn't going to fix that.But with zram taking over half its memory, its into swap and slowing down quicker, and plumb out of memory for big jobs, when it could still be working fine with bigger, albeit probably slower than zram, swap.I've no clue how much the zram compression slows it in terms of thru put.I wiped out the git clone of linuxcnc by re-arranging that SSD yesterday, but I'll do another build later today and see how long it takes with real swap.Thank you. Take care & stay well.. Cheers, Gene Heskett.
I might be wrong, but zram probably wouldn't be so popular if it always consumed 100% of the space allocated to it.
Instead, I believe zram works like this: * The system sets up a zram RAM disk. This will start by consuming a few pages of RAM (plus whatever is required by the driver) * As memory pressure increases (i.e. as RAM starts to fill up with pages), the system will swap the less frequently used pages to a swap device. * In the case of zram, this essentially moves a page from one part of RAM to a smaller representation in another part of RAM. * The zram RAM disk will increase in size, but because of the compression, it will expand at a slower rate than the rate of pages being moved out of RAM, therefore there is a net gain in free RAM. * Similarly, when a page is swapped back from zram to RAM, the RAM disk will shrink by a certain amount (but not by as much as the recovered page will consume)In other words, zram works a bit like a swap disk, but it also acts a bit like compressing data in RAM.
So, applications won't see a slowdown in memory access because they still talk directly to RAM. However, if an application has been swapped to zram, then decompressing the page from zram WILL be quicker than pulling the page from a block device, even an NVMe drive.
OpenPGP_signature.asc
Description: OpenPGP digital signature