Hasty Briefsbeta

Bilingual

Debunking Zswap and Zram Myths

6 hours ago
  • #Linux
  • #Performance
  • #Memory Management
  • Prefer zswap over zram unless you have a specific reason to use zram.
  • zswap integrates with kernel memory management, compresses pages in RAM, and tiers cold data to disk.
  • zram is a compressed RAM block device with a hard capacity limit, leading to potential OOMs or LRU inversion when full.
  • Avoid running zram alongside disk swap as it can push active working sets to slow disk while keeping cold pages in fast RAM.
  • If using zram, pair it with a userspace OOM manager like systemd-oomd or earlyoom.
  • zram on servers has issues with memory usage segregation and cgroup isolation.
  • zswap automatically tiers data between compressed RAM and disk, degrading gracefully under memory pressure.
  • zram's block device architecture treats it like any other storage device, leading to inefficiencies like unnecessary readahead.
  • zswap's integration with memory management allows it to dynamically balance LRU based on pressure.
  • LRU inversion occurs when zram fills with cold data, forcing hot data to disk, worsening performance.
  • zram writeback support exists but requires manual configuration and lacks automatic tiering.
  • zswap handles incompressible data better by rejecting poorly compressed pages and sending them to disk.
  • Using zram can increase SSD wear by shifting pressure to the page cache, leading to more disk I/O.
  • zswap reduces disk writes by acting as a write-reduction filter, absorbing high-frequency page transients.
  • Fedora defaults to zram-only setups for security reasons, avoiding persistent storage of sensitive data.
  • zswap is recommended for most use cases due to better integration with kernel memory management and graceful degradation.