ChrisV opened this issue on Mar 29, 2008 · 36 posts
svdl posted Mon, 07 April 2008 at 11:18 PM
urbanarmitage: no worries, I'm not that easily offended :)
You added a lot of extra detail to my previous post, and you're definitely right about setting up the swap file to use only the faster drives in the system. One of my machines is set up that way: it's got 2 74 Gb Raptor drives (very fast), one 300 GB SATA-II drive (non-NCQ, alas) and one 160 GB PATA drive.
I set up Windows on one of the Raptors, and the swap file on the other Raptor. Extending the swap file to the SATA-II drive didn't increase performance, and extending the swap file to the PATA drive actually did decrease performance. This is consistent with what you wrote.
There's one thing I'd like to correct: when an OS (not only Windows, Linux/Unix and Mac OSX work exactly the same way) swaps out memory, it writes one or more pages of a certain fixed size (OS dependent, in Windows it's 4096 bytes per page) to the swap file. This disk access is cached, so the importance of the disk speed is lessened.
If an application uses a huge amount of swap space, it will usually mean that swapping pages in and out will happen quite often, but not that the transfers themselves will be huge. You can monitor the amount of swapping with Task Manager (the Page Faults column tells you how many pages had to be loaded from the swap file).
When you have a small amount of physical RAM, you'll see that the application will have a lot of page faults per second. A clear indication that you should get more RAM.
A shortage of physical RAM will not only increase the amount of swapping, it will also diminish the performance of the swap file per se. Reason: the amount of memory set aside by the OS for disk caching will also be too small.
Disk cache is the reason that Windows ALWAYS puts application data in the swap file, even if there's more than enough RAM available for Windows itself, the entire application, plus all of its data. The more disk cache Windows has available, the less physical read/writes to the swap file have to occur. And it's the physical disk access that's slow, easily 1000 times slower than memory access.
Disk cache is also the reason that installing more than 2 GB of RAM on a Windows 32 bit system is NOT a waste of resources. The applications may not be able to use the address space, but Windows will use the RAM for disk cache.
The pen is mightier than the sword. But if you literally want to have some impact, use a typewriter