Hacker News new | past | comments | ask | show | jobs | submit login

"Configure the system with no swap file so that it will use all of its spare RAM as file system cache."

That will do EXACTLY the opposite of what he wants. Give it a swap file and unneeded parts of memory will be swapped out to disk, freeing memory for use as a file system cache.

There is _never_ a reason to configure a system without a swap file - except if it's a laptop and you don't want the disk to spin up.

Don't want the system to use swap space? Don't allocate more memory than you have (or buy more memory), but disabling the swapfile never helps. In some cases disabling it doesn't hurt anything, but it never helps.




Why should it ever be acceptable for someone to sit down in the morning to a machine with 4GB+ RAM and have things like a volume OSD take tens of painful seconds to swap in because the night before the machine ran 'updatedb' and the system decided to swap out a few bits of "unused program memory" with a useless cache of the entire disk index?


Then set /proc/sys/vm/swappiness to 0 and be happy.

But actually linux never ejects pages to swap just for the cache. It will only eject pages for memory pressure, which, when freed, can leave extra room for cache. But it won't eject the pages in the first place for the cache.


Since you know its useless, why not just turn off the updatedb cron job?


Because updatedb isn't inherently useless, but rather that file system caching (especially for pages read once) shouldn't eject application pages from RAM to disk.

Being able to run locate and have it quickly return an accurate result is useful at times. I just don't want it paging my entire session out to disk every night in order to do that.


"I just don't want it paging my entire session out to disk every night in order to do that."

It doesn't.


is there any case not having swap hurt ?

assume the RAM alone are enough for heaviest load, no memory leak, no exhaustive ... that's it, the server is never out of RAM memory

hmmm, does hn server use swap?


http://www.openbsd.org/faq/faq14.html

14.4.1 - About swap Historically, all kinds of rules have been tossed about to guide administrators on how much swap to configure on their machines. The problem, of course, is there are few "normal" application.

One non-obvious use for swap is to be a place the kernel can dump a copy of what is in core in the event of a system panic for later analysis. For this to work, you must have a swap partition (not a swap file) at least as large as your RAM. By default, the system will save a copy of this dump to /var/crash on reboot, so if you wish to be able to do this automatically, you will need sufficient free space on /var. However, you can also bring the system up single-user, and use savecore(8) to dump it elsewhere.

Many types of systems may be appropriately configured with no swap at all. For example, firewalls should not swap in normal operation. Machines with flash storage generally should not swap. If your firewall is flash based, you may benefit (slightly) by not allocating a swap partition, though in most other cases, a swap partition won't actually hurt anything; most disks have more than enough space to allocate a little to swap.

There are all kinds of tips about optimizing swap (where on the disk, separate disks, etc.), but if you find yourself in a situation where optimizing swap is an issue, you probably need more RAM. In general, the best optimization for swap is to not need it.

In OpenBSD, swap is managed with the swapctl(8) program, which adds, removes, lists and prioritizes swap devices and files.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: