Re: About the need of a swap area

From: Ville Herva (vherva@niksula.hut.fi)
Date: Sat Jul 27 2002 - 12:01:25 EST


On Sat, Jul 27, 2002 at 06:11:27PM +0200, you [DervishD] wrote:
>
> >Where swap helps perfomance is when you can swap _inactive_ (parts of)
> >programs out, and use the freed memory for disk cache.
>
> Yes, that makes sense, obviously. My question is more: when an
> inactive page will be swapped out? Only when there is no more RAM
> left?

No, it is smarter than that. The exact algorithms are not obvious - even the
linux VM gurus don't quite agree on them :) If you really want to know how
it works, browse at http://www.linux-mm.org - there you can find many
documents on it and plenty of good links.

> How to configure it?

Through the tunables in /proc/sys/vm/.

You can find some explanation for these in beginning of
/usr/src/linux/vm/vmscan.c etc (as of 2.4.19rc3) I don't know if there's
better documentation somewhere.

If you use -ac, recent 2.5 or vendor a kernel, you may find yourself with
Rik van Riel's vm implementation. It may have better documentation - in
different place.

> Except when I'm compiling something large, the memory is almost
> entirely free. I have a lot of memory for having a lot of cache, so
> when I develope things go real fast. For example, I use gcc, make and
> binutils (and an editor) most of the time. Well, thanks to the disk
> cache, the first time they are run is the only disk access...

Yes, that's exactly where disk cache will help you.
 
> But in such a case, highs are the chances of the program crashing
> due to a memory error if there is no swap. I really don't understan
> why swap may save me in this case O:)) Maybe the swap-in, swap-out
> will make that process slower and I have some spare CPU to be able to
> kill the program?

Well, there can be more than one process allocating memory. You shell is
then competing with all of them to get memory. Swap is no magic bullet in
this case either - it just adds more leeway for you.

Rik van Riel wrote:
> The latency difference seems to be on the order of 100000 times. It is
> the latency we care about because that determines how long the CPU cannot
> do anything useful but has to wait.

I stand corrected - I wrote that without thinking.

 
-- v --

v@iki.fi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Jul 30 2002 - 14:00:27 EST