Live data from Hacker News

Linux Performance: Why You Should Almost Always Add Swap Space

haydenjames.io

1–10 of 120 posts

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#2
I'm sorry, but not a single reason was presented in favour of swap when you're 100% confident that you will not max out your RAM. Swap = completely useless slowdown if you have total control over your system.

Better use ulimit to prevent processes with e.g. memory leaks from causing havoc.

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#3
post #2

I'm sorry, but not a single reason was presented in favour of swap when you're 100% confident that you will not max out your RAM. Swap = completely useless slowdown if you have total control over your system. Better use ulimit to prevent processes with e.g. memory leaks from causing havoc.

They presented one reason: the system will swap out more or less unused memory and give that much more space for disk cache, etc.

Now, I'm not sure I find this a particularly compelling reason. I suppose it depends on how much RAM you have available for cache vs how much unused junk gets swapped out. If you've got 5G of unused RAM and 300M extra of stale allocations that get swapped out, then it's probably not going to impact your system in any measurable way.

I personally like a quick OOM, myself, rather than a machine slowing down to a crawl for multiple minutes while swap gets exhausted.

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#4
post #2

I'm sorry, but not a single reason was presented in favour of swap when you're 100% confident that you will not max out your RAM. Swap = completely useless slowdown if you have total control over your system. Better use ulimit to prevent processes with e.g. memory leaks from causing havoc.

RAM freed by swapping some infrequently accessed memory out to disk becomes available for cache use. If you have total control of your system, you know when you can safely allow data to be paged, and when you need to lock memory to physical ram.

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#5
post #2

I'm sorry, but not a single reason was presented in favour of swap when you're 100% confident that you will not max out your RAM. Swap = completely useless slowdown if you have total control over your system. Better use ulimit to prevent processes with e.g. memory leaks from causing havoc.

Can you ever be 100% confident?

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#6
post #2

I'm sorry, but not a single reason was presented in favour of swap when you're 100% confident that you will not max out your RAM. Swap = completely useless slowdown if you have total control over your system. Better use ulimit to prevent processes with e.g. memory leaks from causing havoc.

The most compelling reason to enable at least some swap space is that the Linux kernel's memory handling algorithms can't cope with there being no swap. If you have no swap, then you will encounter stalls and OOMs even if you don't actually run out of memory. Adding even a tiny amount of swap prevents this from happening.

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#8
post #6
post #2

I'm sorry, but not a single reason was presented in favour of swap when you're 100% confident that you will not max out your RAM. Swap = completely useless slowdown if you have total control over your system. Better use ulimit to prevent processes with e.g. memory leaks from causing havoc.

The most compelling reason to enable at least some swap space is that the Linux kernel's memory handling algorithms can't cope with there being no swap. If you have no swap, then you will encounter stalls and OOMs even if you don't actually run out of memory. Adding even a tiny amount of swap prevents this from happening.

This sounds as if it is a serious issue and should be fixed. Is there a bug report about it?

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#10
post #6
post #2

I'm sorry, but not a single reason was presented in favour of swap when you're 100% confident that you will not max out your RAM. Swap = completely useless slowdown if you have total control over your system. Better use ulimit to prevent processes with e.g. memory leaks from causing havoc.

The most compelling reason to enable at least some swap space is that the Linux kernel's memory handling algorithms can't cope with there being no swap. If you have no swap, then you will encounter stalls and OOMs even if you don't actually run out of memory. Adding even a tiny amount of swap prevents this from happening.

i agree with this , lack of swap makes oom too aggressive . , question what's worst no app (and react to OOM) or app swapping
Post reply on HN