Hacker News

Top stories

Live mirror
30 storiesupdated just nowView source snapshot
  1. Linux support is coming to Snapdragon X2 Series(qualcomm.com)
    124comments
  2. Claude discovers a novel enzyme system with CRISPR-like repeats(anthropic.com)
    588comments
  3. Show HN: How long do I need to work at my salary before I can coast, or retire?(github.com/karmanyaahm)
    20comments
  4. ArXiv receives multiyear commitments to support it as an independent nonprofit(arxiv.org)
    14comments
  5. Feds Target AI Critics as "Foreign Agents"(kenklippenstein.com)
    144comments
  6. Making portable my unportable transputer C compiler(nanochess.org)
    2comments
  7. VSCode's SSH Agent Is Bananas (2025)(fly.io)
    109comments
  8. Virtio-nvgpu: Near-native Nvidia GPU access inside a KVM guest(github.com/nestrilabs)
    17comments
  9. The "Windows XP Box" (2003)(mini-itx.com)
    12comments
  10. Meta VR Glasses(meta.com)
    273comments
  11. Ideas on modernizing the open-source desktop(lwn.net)
    4comments
  12. Fixing the Portobello Police Station Clock(pointinthecloud.com)
    95comments
  13. Mercury 2.5 LLM hits 770 tokens per second(artificialanalysis.ai)
    49comments
  14. Why 'What's Opera, Doc?' looks like that(animationobsessive.substack.com)
    1comments
  15. Lambda MicroEgg(philipzucker.com)
    discuss
  16. Italian parliament votes for return to nuclear energy(apnews.com)
    427comments
  17. The mystery animal on an ancient god's head(signoregalilei.com)
    24comments
  18. Making Tailscale Faster(tailscale.com)
    43comments
  19. Australia says OpenAI agent hacked into government website(channelnewsasia.com)
    51comments
  20. Data liberation: Apache Kafka's native cluster mirroring(redhat.com)
    discuss
  21. A brief history of Windows scroll bar shortcuts(devblogs.microsoft.com/oldnewthing)
    62comments
  22. Solving for faster SHA-1 collision detection(sam.dev)
    1comments
  23. Show HN: An open-source manufacturing ERP/MES/QMS(carbon.ms)
    11comments
  24. LensVLM: Compressing long context as images, expanding only relevant pages(huggingface.co)
    7comments
  25. Tokens too cheap to meter(jyn.dev)
    188comments
  26. The Curious Power of Punctuation(newyorker.com)
    10comments
  27. Gemini 3.8 text-to-speech(blog.google)
    127comments
  28. FLAWED's Flaws and What This Means for Industry Research(suhacker.ai)
    2comments
  29. Radicle: Disclosure of Vulnerability in the Network Protocol(radicle.dev)
    52comments
  30. We just shipped support for the ugliest part of HTTP: Vary(cloudflare.com)
    23comments

Swap, ZRAM, Zswap and Hibernate on NixOS

55 pointsby 11h agoblog.matthewbrunelle.com
15 comments
8h agoHN ↗

Thanks for this. So weird though - I literally spent the better part of the weekend reading and learning all about the differences between zram and zswap and ultimately deciding to switch out my previous zram config for zswap on my NixOS system! So seeing this pop up on my hackernews feed felt a bit spooky…

3h agoHN ↗

same, I literally just set up my Framework 13 Pro today and was looking for the current recommended zswap settings... looks like a bunch of us are in this thread

7h agoHN ↗

Right, you are good to do swap files on btrfs since linux 5.0 or so as long as you follow some rules. Disko thankfully covers all those details for you, but I shouldn't have skipped over that in the piece. I'll make an update when I get a chance.

6h agoHN ↗

Swap files work, but I wouldn't quite say "you are good to do swap files on btrfs" because the official documentation (the page I linked earlier) says

filesystem - must be only single device

This means swapfiles will have an amplified impact, much larger than the size of the swapfile itself.

Users should be aware of the impact when using swapfiles alongside other data. This is especially discouraged for root filesystem.

If a swap file is the only thing that will work with your setup, then it's fine to use one, but if you're at all able to use a swap partition, then that's a far better choice. (Swap files are fine on ext4 and xfs; it's only COW filesystems like btrfs and zfs where they should be avoided.)

2h agoHN ↗

While everything else is pretty obvious from the nature of an unmovable file, "scrub will skip those block groups which have extents of an active swapfile on them, and those block groups may also contain extents belonging to other files".

Then again, I mostly use XFS, which has no data checksums at all, so YMMV.

5h agoHN ↗

I've had good luck using zswap+zstd on Ubuntu 26.04. I have a Framework 13 (AMD) with 16GB, and have a 16GB swap file configured (ext4 root partition).

I had planned to upgrade the machine to 32GB of RAM but I don't really feel it's necessary at this point. Which is obviously great given the current RAM costs!

4h agoHN ↗

I also just recently enabled zswap on my NixOS setup, it's been working fine. I have 32GB of RAM and 64GB of swap, so I really don't need it, but it hasn't hurt.

I was expecting some problems with my switch to NixOS back in June, but it's been just superb. Even things like building deb packages for my Ubuntu 26.04 machines at work have not been a problem at all.

I had dabbled with NixOS for a year or two before making the switch and had some familiarity with the nixlang and various concepts (SOPS, age, flakes). But, what really smoothed out the switch was using Claude Code to develop the NixOS configs. Everything is easy to do that way, and any issues are easy to back out.

1h agoHN ↗

Claude code/Git/NixOS is such a nice system to work with.

You can build your entire system from a worktree and merge if it works or boot the old generation if it doesn't. This is great for trialing new kernels, NixOS releases, or alternate Window managers, and rolling back is trivial.

One downside is that there is only one stable NixOS at a time, and no LTS. However in practice I haven't found this to be an issue across multiple desktops, servers and SBCs.

3h agoHN ↗

Not on nixOS, but I thought I would weigh in on my preferred value for swappiness. 0. For some reason when I have a month of uptime (and I suspend once a day), doing anything with the desktop environment for the first time in a few hours causes a micro stutter for maybe 100ms, as if having to swap out from disk. Turning swap off and on again (meaning no pages are swapped to disk anymore) immediately fixes it. Opening a new tab, pressing the super key even performing certain actions in a video game cause the stutter. I know the internet tells me that 0 isn't a good value, but my computer becomes noticeably worse to use even with a swappiness of 5. I have enough RAM for anything I want to use this computer for, so swap is just for suspend for me.

3h agoHN ↗

Agree. I tried using a swapfile last year-ish, as the internet experts tell you to. I have 64GB of RAM. If I fresh boot and start a few apps I'll be using maybe 16GB RAM + 0GB swap. Then a few hours later I see I'm using 8GB of RAM + 8GB of swap... why? Why did Linux waste IO moving data to disk when there's no memory pressure?

That's why I don't use swap.

2h agoHN ↗

I suspect the intent is to move stale things out of RAM so it can be immediately used for more productive purposes when needed.

Shuffling out 8GB with a spinning hard drive could take a full minute…

That said, I agree with you. I’d rather not use swap unless absolutely necessary and I don’t want the latter to happen either…

Plus, I don’t want my storage in the “critical path” of memory accesses, even if rare.

2h agoHN ↗

Generally the idea is that regions of memory that aren't being used are swapped out to disk, then other more useful things are brought into memory.

For example: you have a background program that you're not using and in the foreground you're crunching data from disk. In this scenario the most efficient use of your memory is to swap the background program out and pull the disk data into RAM.

1h agoHN ↗

But why should it swap things out even when I'm not crunching data and there's no memory pressure? I'd rather everything stay in memory and stay fast, since I have enough RAM.

1h agoHN ↗

whether to use zram or zswap depends on what your intentions are, hibernation doesn't matter (use priority)

if your intention is to have enough compressed ram such that you never reach the limit (compression ratios are usually around 3 with zstd) you can allocate over 100% of your ram in zram. then have 100% of your ram as a swap partition for hibernation. this works extremely well but should you exhaust your zram swap serious problems may begin.

zswap will be using your SSD and putting wear on it and also imposing latency spikes on old page access, only makes sense if you are certain your swap usage may spike too high in my opinion.