Showing posts with label swap file. Show all posts
Showing posts with label swap file. Show all posts

Monday, 30 January 2012

Linux Swap File vs Swap Partition


from http://en.wikipedia.org/wiki/Paging#Linux

Interesting piece on swap files from Andrew Morton himself.

.. "From a software point of view with the 2.6 Linux kernel, swap files are just as fast[14][15] as swap partitions. The kernel keeps a map of where the swap file exists, and accesses the disk directly, bypassing caching and filesystem overhead.[15]"

Q.) Does creating the swapfile on a journaled filesystem (e.g. ext3 or reiser) incur a significant performance hit?

A.) None at all. The kernel generates a map of swap offset -> disk blocks at swapon time and from then on uses that map to perform swap I/O directly against the underlying disk queue, bypassing all caching, metadata and filesystem code."

The implication is as follows: "With a 2.4.x kernel swap files were slower than swap partitions, but with the 2.6 kernel a swap file is just as fast as a swap partition."

Of course this depends on the following:

1.) That the swapfile is in contiguous space and therefore not fragmented
2.) That you have any need or desire to use a pagefile. Swap partitions work perfectly well.
3.) You're running a 2.6+ Kernel.