3 ms·
You should still use swap. It's not "2x RAM" as advice anymore, and hasn't been for years: https://chrisdown.name/2018/01/02/in-defence-of-swap.html https://chr
by SCdF 8mo ago
You should still use swap. It's not "2x RAM" as advice anymore, and hasn't been for years: https://chrisdown.name/2018/01/02/in-defence-of-swap.html https://chrisdown.name/2018/01/02/in-defence-of-swap.html
tl;dr; give it 4-8GB and forget about it.
- ch_123 8mo agoI've heard "square root of physical memory" as a heuristic, although in practice I use less than this with some of my larger systems.
- man8alexd 8mo agoThe proper rule of thumb is to make the swap large enough to keep all inactive anonymous pages after the workload has stabilized, but not too large to cause swap thrashing and a delayed OOM kill if a fast memory leak happens.
- boomlinde 8mo agoThat's not so much a rule of thumb as an assessment you can only make after thorough experimentation or careful analysis.
- man8alexd 8mo agoYou don't need "horough experimentation or careful analysis". Just keep free swap space below few hundred megabytes but above zero.
- boomlinde 8mo ago"Keep swap space below few hundred megabytes but above zero" is a good example of a rule of thumb. "Make the swap large enough to keep all inactive anonymous pages after the workload has stabilized, but not too large to cause swap thrashing and a delayed OOM kill if a fast memory leak happens" is not.
- NoGravitas 8mo agoIt doesn't take that much experimentation, though. Either set up not enough swap and keep increasing it by a little bit until you stop needing to increase it, or set up too much, and monitor your max use for a while (days/weeks), and then decrease it to a little more than the max you used.
- SAI_Peregrinus 8mo agoI went with "set up 0 swap" and then never needed to increase it. I built my PC in 2023, when RAM prices were still reasonable, stuck 128GiB of ECC DDR5 in, and haven't run into any need for swap. Start with 0, turn on zswap, and if you don't have enough RAM then make a swap file & set it up as backing for zswap.