Swap: Difference between revisions

Line 79: Line 79:
== Zswap swap cache ==  
== Zswap swap cache ==  


[https://docs.kernel.org/admin-guide/mm/zswap.html Zswap] is a compress RAM cache for swap pages. It acts as a middle layer between system memory and a traditional disk-based swap device, storing compressed pages in RAM before optionally writing them out to disk-based swap if necessary.
[https://docs.kernel.org/admin-guide/mm/zswap.html Zswap] is a compressed RAM cache for swap pages. It acts as a middle layer between system memory and a traditional disk-based swap device, storing compressed pages in RAM before optionally writing them out to disk-based swap if necessary. It acts as an LRU cache.


Unlike zram, zswap requires a disk-based swap device to back it.
Unlike zram, zswap requires a disk-based swap device or file to back it.


Zswap is controlled by kernel parameters and can be enabled in your NixOS configuration by setting appropriate options through <code>boot.kernelParams</code>.
Zswap is controlled by kernel parameters and can be enabled in your NixOS configuration by setting appropriate options through <code>boot.kernelParams</code>.
Line 91: Line 91:
     "zswap.compressor=lz4" # compression algorithm
     "zswap.compressor=lz4" # compression algorithm
     "zswap.max_pool_percent=20" # maximum percentage of RAM that zswap is allowed to use
     "zswap.max_pool_percent=20" # maximum percentage of RAM that zswap is allowed to use
    "zswap.shrinker_enabled=1" # whether to shrink the pool proactively on high memory pressure
   ];
   ];
</nowiki>
</nowiki>