Linked by David Adams on Thu 20th Nov 2008 04:19 UTC
General Unix Linux and other Unix-like operating systems use the term "swap" to describe both the act of moving memory pages between RAM and disk. It is common to use a whole partition of a hard disk for swapping. However, with the 2.6 Linux kernel, swap files are just as fast as swap partitions. Now, many admins (both Windows and Linux/UNIX) follow an old rule of thumb that your swap partition should be twice the size of your main system RAM. Let us say I’ve 32GB RAM, should I set swap space to 64 GB? Is 64 GB of swap space really required? How big should your Linux / UNIX swap space be?
Thread beginning with comment 337865
To view parent comment, click here.
To read all comments associated with this story, please click here.
siride
Member since:
2006-01-02

It's because a SWAP partition doesn't require interaction with the VFS. Reads and writes and allocations can be done more directly. If you use a SWAP file, then you have filesystem overhead. In the older days, I suppose this was considered too slow to get good performance. I doubt it's a problem today, but people are slow to change.

Perhaps you should run some SWAP benchmarks and see if a SWAP file is considerably slower. I won't do it because I don't really care ;) .

Reply Parent Score: 2

MattPie Member since:
2006-04-18

It's because a SWAP partition doesn't require interaction with the VFS.

Also, swap files that grow fragment over time, which makes the disk head jump around looking for blocks that should be contiguous. Granted, having a swap file on a separate part of the disk isn't much better, but the performance will be constant, not degrading over time.

Reply Parent Score: 2

sbergman27 Member since:
2005-07-24

Swap really belongs in the middle of the disk. Not way out at the beginning or end of the disk, where it's furthest from the filesystem wrt seek time. I should note that reduction of seek time is likely to outweigh any factors of raw throughput performance at various places on the drive. In my experience, swap seldom streams. It seeks.

Reply Parent Score: 2

google_ninja Member since:
2006-02-05

I don't know about HFS+ for mac, but NTFS on windows actually does its best to keep system files and the page file near the center of the physical disc. I don't know how difficult that would be to implement on Ext (I know there are alot of fundamental differences in the way that the two filesystems work), but IMO for pagefiles at least NTFS has the better solution. It is something that the system should be able to figure out by itself based on usage patterns, not something users should have to worry about.

Reply Parent Score: 3