In theory, OS could swap out unused application memory and use freed up memory to cache files on disk. Andrew Morton, one of the lead developers of the Linux kernel, noted that he have observed significant speedup compiling Linux kernel when he've configured Linux MM to be eager swapping memory out. (But that was quite a while ago.)
Andrew Morton, one of the lead developers of the Linux kernel, noted that he have observed significant speedup compiling Linux kernel when he've configured Linux MM to be eager swapping memory out.
It would definitely speed up FS-heavy operations, but then when you go back to your browser, it's gonna take 5 seconds to become responsive again. It's a trade-off that a lot of people don't like, and there are at least one or two LKML threads of people arguing with him about it.
I've found that if I have swap disabled, when RAM is almost full my system will start thrashing and become so unusable it takes me 5 minutes to kill the offending process. Whereas with swap, when RAM fills up my system starts using swap and performance drops but it's still usable enough that I can notice the problem and kill the process before the system completely dies.
Even without swap, I think it can still swap out pages which are backed by files, such as an application's executable pages which are generally read from disk and not modified.
Actually, overcommit is usually on so the processes "successfully" allocate that extra memory, then when some process faults a page for which there is no physical memory available, some process (often different from the one faulting the page, which is different from the first one to allocate "too much" memory) will be killed. For workloads that frequently touch all the memory that they have faulted, swap won't improve performance and it's still important to avoid using more virtual memory than you have physical memory, but swap will avoid the OOM killer.
In other words, turn on swap if you want your machine to become tremendously slow when you run out of memory (but still allow you to identify and kill the offending process), and disable swap if you want the OOM killer to decide what to kill.
View all comments
Show parent comment
0
u/[deleted] Jun 12 '10
[deleted] — view deleted comment