9 ms·
This is misleading, as the kernel will often swap out processes rather than shrink the disk cache. Its tendency to do this is controlled by the vm.swappiness p
by colanderman 16y ago
This is misleading, as the kernel will often swap out processes rather than shrink the disk cache. Its tendency to do this is controlled by the vm.swappiness parameter, which by default heavily favors swapping: http://kerneltrap.org/node/3000 http://kerneltrap.org/node/3000
Decreasing this value will favor reducing the cache size and will tend to increase responsiveness. You can set it in the /etc/sysctl.conf file. Low values (≤ 5) are especially good for SSDs where you want to minimize swap usage.
- kindlyviking 16y agoThe article mentions this on the second page at the bottom: http://www.linuxatemyram.com/play.html http://www.linuxatemyram.com/play.html
- colanderman 16y ago"But look you found the notice didn't you?" "Yes," said Arthur, "yes I did. It was on display in the bottom of a locked filing cabinet stuck in a disused lavatory with a sign on the door saying 'Beware of The Leopard'."
- jerf 16y agoI often just turn swap off entirely. A normal workload on my 4GB linux machine will frequently fail to fill even 2GB of buffers. At the moment my machine has still managed to fail to fill 800MB of my RAM with anything and I'm running two virtual machines and doing my usual work load. I do have a swap partition but only so I can hibernate.
- requinot59 16y ago> I often just turn swap off entirely. And you're smart to do so. Swap is useless for 99% of end-user systems. ChromeOS doesn't use any swap partition, for instance. As for hibernation, it's not available if you use a crypted swap, which is wise to use (at least on a laptop). As a result, I, too, disabled swap completely.
- jerf 16y ago"And you're smart to do so." Finally, that's the first comment I get, instead of someone extolling the virtues of swap and babbling warmed-over 1990s rules of thumb about "twice the RAM is the recommended size of your swap file" as if I'm going to wait for even 200MB of swap to fill up before flipping out and killing the offending process, let alone 8GB.
- requinot59 16y ago> "twice the RAM is the recommended size of your swap file" Don't listen the parrots that repeat something that ceases to be true at least 10 years ago. Swap used to be a useful hack, it is not anymore. > as if I'm going to wait for even 200MB of swap to fill up before flipping out and killing the offending process Well said ;-)
- cookiecaper 16y agoHibernation requires a large swap space, doesn't it? Last I knew it did, perhaps you can compress it now.
- jerf 16y agoYes, and it may seem a merely semantic difference, but there's still a difference between "swap space" and "hibernation backing". One I'm willing to wait for while it fills, the other, I am not. The kernel may not distinguish, but I do. When I don't care about hibernation I just remove it.
- cookiecaper 16y agoRight, swapoff is totally acceptable imo if you're having trouble with swap. I was commenting on how "double the size of RAM" is a bad or outdated guideline. There's been a few times where I've regretted not making my swap space big enough, sometimes when getting a RAM upgrade and wanting to do hibernation, etc. My disk isn't super pressed for space so in my mind there's no real reason to be stingy, and then you don't have to grow/shrink partitions if an upgrade occurs after the initial disk setup.
- nwmcsween 16y agoSwap is mainly an emergency backing, i have nagios message me whenever swap hits x amount depending on the server, it's better than oom killer picking off processes.
- requinot59 16y agoIt might be better to use proper rlimits, and not let a mad process gone wild triggers the OOM. Swap just delays the problem.
- nwmcsween 16y agoThe problem with set number limits is that changes in software and hardware require changes in limits - it's easier to just watch swap and get notified.
- deleted 16y ago[deleted]
- stcredzero 16y agoIs there a way to decrease the swappiness of OS X?
- jacques_chester 16y agoLow swappiness is also useful in tightly controlled VPSes. Swap is absolute murder on a VPS platform. I leave it on as emergency backstop, but otherwise I have turned down to 0. I simply do not want processes swapped out, ever.