nixos-apple-silicon icon indicating copy to clipboard operation
nixos-apple-silicon copied to clipboard

Enable Zswap

Open foldfree opened this issue 1 year ago • 5 comments

Marcan is recommending to use Zswap instead of Zram for devices that have under 24gb of ram because unified memory is conflicting with zram. See this reddit announcement

Below is a way to add zswap using theses settings as a reference:

./configuration.nix

  boot = {
    kernelParams = [
      "zswap.enabled=1"
      "zswap.compressor=zstd"
      "zswap.zpool=zsmalloc"
      "zswap.max_pool_percent=50"
    ];
  };

./hardware-configuration.nix

 swapDevices = [ {
    device = "/var/lib/swapfile";
    size = 16*1024;
  } ];

There might be a seamless solution via AppleSiliconsupport flake, though this is outside my area of expertise. Currently, Fedora Asahi uses LZ0 compression, but since zstd is already enabled in asahi-nixos kernel, I opted to use that instead.

foldfree avatar Nov 24 '24 10:11 foldfree

FYI: My kernel log says: "compressor zstd not available, using default lzo" That's on 6.12.4-asahi...

docbobo avatar Jan 30 '25 15:01 docbobo

FYI: My kernel log says: "compressor zstd not available, using default lzo" That's on 6.12.4-asahi...

same for me

sioodmy avatar Mar 01 '25 15:03 sioodmy

@docbobo I found a solution https://github.com/sioodmy/dotfiles/commit/c391b65bd39f3aab11865920b1afeab8aae30459

sioodmy avatar Mar 01 '25 16:03 sioodmy

I'm still seeing compressor zstd not available, using default lzo on 6.12.12-asahi.

@docbobo I found a solution sioodmy/dotfiles@c391b65

This is not a solution, you are switching from zswap to zram (these aren't the same thing). zstd is probably faster than lzo for most memory-intensive workloads at this point given how fast Apple Silicon is, so it would be very nice to have this in the kernel.

waltmck avatar Mar 12 '25 14:03 waltmck

zstd is included in #341, which should close this issue if merged.

waltmck avatar Sep 16 '25 04:09 waltmck