Remix.run Logo
ch_123 14 hours ago

I'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 14 hours ago | parent [-]

The 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 13 hours ago | parent [-]

That's not so much a rule of thumb as an assessment you can only make after thorough experimentation or careful analysis.

NoGravitas 9 hours ago | parent | next [-]

It 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 8 hours ago | parent [-]

I 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.

man8alexd 13 hours ago | parent | prev [-]

You don't need "horough experimentation or careful analysis". Just keep free swap space below few hundred megabytes but above zero.

boomlinde 13 hours ago | parent [-]

"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.