[linux-elitists] Performance issues with swap file vs. swap partition

Jesse Hutton jhutton@eden.rutgers.edu
Thu Nov 6 08:08:07 PST 2003

On Thu, 6 Nov 2003, Peter Whysall wrote:

> Whilst pondering the filesystem layout for a new box, a dim and distant
> memory was awakened; namely, the idea that under Linux 2.4, swapfiles
> give away no performance to swap partitions.
> Googling for this produced a very unhelpful set of results, with more
> questions than answers.

(http://www.ssc.com/pipermail/linux-list/1999-April/041352.html )

Bradford Hull wrote:
>         Swap to a swap file has to work out where to write swapped memory
> to the file by:
>         1) Ask the filesystem where the file is.
>         2) Locate the cluster the appropriate blocks would go in the file.
>         3) Write them there.
>         4) If there's more than a cluster worth, look for the location
>            where the next cluster physically resides.
>         5) Write there.  Repeat 4 and 5 until done.
>         Swap to a swap partition consists of:
>         1) Write to the physical location within the partition the swapper
>            wants to write to.
>         There's a lot less overhead, and from personal experience, the
> speed difference is pretty large.  If you have a lot of memory in the system,
> so you don't swap much, it won't matter much, but if you do big memory-using
> things like use gimp, show large images, use netscape or compile c++ it
> will tend to make a big difference.

Seems valid to me, even though block device performance has greatly
improved since the original date of this posting (especially in 2.5/2.6,
I'm thinking--not sure about 2.4 series).


More information about the linux-elitists mailing list