Windows – Swap file fragmentation: fact or fiction

fragmentationpagefileperformanceswapwindows

This is about Windows, but I'm sure it applies to other OS as well.

I've heard people say that if you want better performance, you should avoid swap file fragmentation. To do this, you can either manually specify a constant size for the swap file, or even move it to a dedicated partition/disk.

Will this really give any performance benefits? After all – the swap file is accessed in a randomized manner anyway, what's a bit more randomization? And if you're considering a separate disk for the swap file, then you would be far better off investing your money in more RAM instead. Unless you happen to get a free disk of course.

So – is there a point in fighting swap file fragmentation or not?

Best Answer

Pagefile fragmentation will only be a significant factor in extreme cases. Fragmentation is a factor when large files are read serially, but this almost never happens with the pagefile. Pagefile access is in small blocks of no more than 64K, and this will be usually mixed with access to other files. It matters little if the pagefile is fragmented or not, the disk heads will be moving around in any case.

None of this really matters unless pagefile performance is a limiting factor. And it usually isn't. Most paging doesn't use the pagefile at all. By design the pagefile is used to store data that is not accessed frequently. In most cases the pagefile isn't accessed often enough for it's performance to matter.

In most cases this is just much adu about nothing. The misquided attempts to solve the problem can, and often do, cause serious problems.