Thread (85 messages) 85 messages, 22 authors, 2005-03-01

Re: swp - Re: ext3 journal on software raid (was Re: PROBLEM: Kernel 2.6.10 crashing repeatedly and hard)

From: Mike Hardy <hidden>
Date: 2005-01-06 01:28:00

Guy wrote:
So, the question is:
	Assume I have enough RAM to never need to swap.
	Do I need any swap space with Linux?
This has been hashed out at great length on linux-kernel - with a few 
entrenched positions emerging, if I recall correctly.

There are those that think if they size the machine correctly, they 
shouldn't need swap, and they're right.
I had 8 Meg of swap space.  So 12 meg total available virtual memory.
One day I added 16 Meg of RAM.  So now I had 20 Meg of RAM.  I deleted my
swap space.  Everyone told me I needed 20-40 Meg of swap space now!  Swap
space should be 2 time RAM size.  How crazy, my memory requirements did not
change, just the amount of memory.  I used that system for a year or so like
that.  Go figure!
This story pretty much sums up that position, and I've certainly been in 
that position myself.

There are others (notably the maintainer of part of that code - Andrea 
Arcangeli if I recall correctly, though I apologize if that's a 
misattribution) who believe you should always have swap because it will 
allow your system to have higher throughput. If you process a large I/O, 
for instance, the kernel can swap out live processes to devote more RAM 
to VFS caching. That hurts latency though, and the nightly slocate run 
is a pathlogical example of this. You wake up in the morning and your 
machine is crawling while it swaps everything back in.

There's a "swappiness" knob you can twiddle in /proc or /sys to alter 
this, but the general idea is that you can improve throughput on a 
machine by having swap even if there is enough ram for all processes

I've got machines with and without swap, but I typically run all servers 
with swap to handle ram-usage spikes I'm not expecting (you never know) 
while I run my laptop without swap when possible to avoid latency issues 
with swappiness.

As with all things, its policy decisions and tradeoffs :-)

-Mike
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help