I’m noticing that a very intended behavior of Zswap is to write pages to disk when they don’t cleanly compress (or for some other reason). How can I configure it to act kind of like Zram but only writeback when the system is actually out of RAM?

grep -R . /sys/kernel/debug/zswap/
/sys/kernel/debug/zswap/stored_incompressible_pages:8224
/sys/kernel/debug/zswap/stored_pages:218538
/sys/kernel/debug/zswap/pool_total_size:229318656
/sys/kernel/debug/zswap/written_back_pages:251371
/sys/kernel/debug/zswap/decompress_fail:0
/sys/kernel/debug/zswap/reject_compress_poor:0
/sys/kernel/debug/zswap/reject_compress_fail:0
/sys/kernel/debug/zswap/reject_kmemcache_fail:0
/sys/kernel/debug/zswap/reject_alloc_fail:0
/sys/kernel/debug/zswap/reject_reclaim_fail:0
/sys/kernel/debug/zswap/pool_limit_hit:0

My parameters: zswap.enabled=1 zswap.compressor=zstd zswap.shrinker_enabled=0 zswap.max_pool_percent=20. Swappiness is at default value.

  • nous@programming.dev
    link
    fedilink
    English
    arrow-up
    0
    ·
    2 days ago

    Define ‘actually out of ram’. If it is writing to swap then it is out of ram. That ram might not all be used by application memory, it could be used by the filesystem cache. Both are important for performance of applications. If you only favour application memory then it it will constantly dump files it has recently read and might be still required by applications rather then dropping some unused application memory instead.

  • Die4Ever@retrolemmy.com
    link
    fedilink
    English
    arrow-up
    0
    ·
    2 days ago

    I don’t think Zswap can be tuned like that.

    The idea is that the Linux kernel wants to get rid of this page of memory only because it has something better to use that memory for. So if it’s uncompressible then it should go to swapfile for optimal performance. Otherwise it means something else is getting kicked to swapfile, and it wasn’t the kernel’s first choice to be moved to swap so that’s even worse, and what happens if that is also uncompressible? Now you’ve got a cascading failure.