Re: why swap at all?

From: John Bradford
Date: Thu May 27 2004 - 03:00:08 EST


Quote from Kyle Moffett <mrmacman_g4@xxxxxxx>:
> On May 26, 2004, at 12:58, John Bradford wrote:
> >> A lot of people feel subjectively that swap makes a system slow.
> >> There's
> >> anecdotal evidence that swap does horrible things or "must be badly
> >> broken
> >> because the machine gets slow" on almost every operating system that
> >> supports swapping. In most cases, it's just a case where the real
> >> working
> >> set has exceeded physical memory, and in that case, swap is just
> >> doing what
> >> it's supposed to be doing.
> > It's true that physical RAM or swap, over and above the minimum needed
> > for
> > the working set is usually beneficial. However where there is
> > physical RAM
> > which will never be touched during normal usage, adding swap will not
> > be
> > beneficial.
>
> If your RAM happens to be large enough to contain not only everything
> on disk
> you ever want to even read *and* all the space you need for
> calculations, then
> you have nothing to gain from using swap. On the other hand, if you
> are say,
> grepping through a kernel source tree, the first time it is read from
> disk, but after
> that it is stored in cache in your RAM. If you have swap, anonymous
> pages of
> RAM that are not in use can be paged out while you do your grepping,
> even if
> you are grepping through a 900MB+ dataset and only have 1GB RAM. Swap
> allows non-filesystem-backed pages to be pushed to disk for some
> filesystem
> backed pages to be loaded and used.

Think about it - you seem to be suggesting that adding more and more swap will
free up more and more physical RAM to be used as cache, but that it not really
true, because once you've freed up all of the physical RAM, there is no more
to free up.

That it not to say that there is no point in having more swap than physical
RAM at all, rather that once all non-filesystem-backed pages apart from cache
have been pushed out to swap, (and note that executables can and will be pushed
out to swap independently of swap space anyway), all that additional swap
space will allow is to run more processes, or move cache out to swap, which
admittedly could give a performance benefit in some instances, but in most
cases I think it would be minimal.

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