Comprehensive Guide to the Windows Paging File
busfahrer writes "Adrian's Rojak Pot has a nice article about the internals of the Windows paging file. It explains what a paging file is and lists the differences between a swapfile and a paging file. But first and foremost, a large part of the article deals with the various methods of optimizing the Windows paging file, thus yielding a notable performance gain for people who are not overly blessed with RAM."
Picks up red phone.
Hello?
Voice on phone: No, the white phone.
picks up white phone.
Hello?
PA system: Would Mr. File please pick up one of the white courtesy phones?
(shouting) I've got it!
PA system: Thank you
Unknown host pong.
OMG, you mean you didn't read the article and possibly learn something?
/. world.
Honestly, I wonder why people take the high and mighty road. The number one problem with computers is people simply don't understand them. The number one way to solve this problem is to educate the user about these little facets of the OS.
The article covers some very basic differences in plain english, and unlike the 'just to do this and leave me alone' attitude, puts the user one step closer to a positive computer experience... a tough thing in today's virus/trojan/adware
"The more pity, that fools may not speak wisely what wise men do foolishly" - Touchstone,Shakespeare's "As You Like It"
One of the biggest performance helps is to keep the paging file from being fragmented, and I'm not talking about three or four fragments.
The best way to avoid fragmenting the swap file is a method I learned a long time ago, and the author mentions in his article but doesn't talk about much: keeping it on a separate partition. Sure, NTFS doesn't have a swap partition type like Linux does, but I keep a 2 gig partition with a fixed-size swap file on my WinXP box. Set the registry key to ignore "out of space" warnings for that drive, remove read privileges from everybody to that drive, and you basically have an invisible, un-fragmentable swap file that is invincible to user stupidity (I share my computer with my wife, so that last point is important. She does not have Administrator privileges on my box).
24 beers in a case, 24 hours in a day. Coincidence? I think not!
http://www.bysoft.com/freeram.asp
A free application that you can use to 'pre-page' out pages right before loading up your application. What it does is hog as much RAM as much as it can, forcing the OS to page out any unnessecary applications.
I've seen the standard Explorer + lsass + cwrss + all the svchosts memory footprint go from 80-ish megs to 20. Running this before your game will allow quick load-times and quicker performance.
This seems unfair since I'm assuming you have admin privs on her box
What are you talking about?! Men never have admin privs on a woman's box.
Viral software licensing is not freedom, it is in fact GNU/Socialism.
Frankly, I'm impressed you even clicked on the link.
At least, not after marriage.
-- Thou hast strayed far from the path of the Avatar.
There's a good reason why people don't write about VM systems often; the combination of writing skill and the ability to understand modern VM is extremely rare.
Take most, if not all, of what the article discusses with a large grain of salt. Everything, from his history (did Microsoft invent demand paging? Hardly) to his terminology is flawed.
Just reading the first 40 comments or so here reveals that VM remains one of those "black magic" areas, where reason is overcome by superstition and people will assert the most ridiculous, irrational and unsupportable things. Regrettably, the contents of this article do nothing to improve the situation.
= Mike
SysInternals (who make some of the best freeware available for Windows) has PageDefrag. It defrags your registry hives and pagefile at boot, before Windows loads. Very slick program and free to boot.
Entrepreneur : (noun), French for "unemployed"
Well, since you've had four incorrect and or unhelpful responses so far, let me shed some light:
/proc/sys/vm/swappiness. This can be set on a value from 0 (try to never swap) to 100 (agressively write out pages to disk). By default, it is set to 60. To change the swappiness, say, to 40:
Linux only has a paging file (it's still called swap space though). This can either be a hard drive partition, or a regular file.
To make it as a regular file:
dd if=/dev/zero of=some_file bs=1M count=however_big_you_need_it_in_megs
Then:
mkswap some_file
Then:
swapon some_file
You don't need to reboot, and you can add/remove these files at will using swapon/swapoff and the normal filesystem tools.
The 'swappiness' of Linux can also be tuned: since kernel 2.6.0 there has been a proc file
echo 40 >/proc/sys/vm/swappiness
Most 2.6-based distros have some GUI tool that can tweak parameters like this (Fedora certainly does).
Oolite: Elite-like game. For Mac, Linux and Windows
Well, they tried, but I think they really missed some very commonly-held misconceptions.
I've just finished a project involving reconstructing process images from physical memory, including pages from swap, if available, so I've got a pretty good understanding of this stuff at a very low level.
Misconception 1: Swap-file usage = performance degradation
Yes, it is slower (usually by 3 orders of magnitude, not 1) to access a page (frequently 4K) from disk instead of memory. HOWEVER, effiency dictates that all available RAM be utilized as soon as possible.
For example, in addition to running processes, we also use volatile memory storage to cache file data. Clearly, we want to cache as much as possible. Page replacement policies then become important to determine how much swap space to use. But usually it is much greater than 0, because we've got process image pages that are less frequently used than a lot of file cache pages. So we've gotta remember that data, but we don't wanna waste fast RAM on it.
In other words, isn't it great that we can swap out pages from an unused process to make room for frequently accessed file data? Regardless of how much memory we have, that's a Good Thing.
Misconception 2: Virtual memory = disk space
Virtual memory is a mechanism for translating program-visible addresses to arbitrary storage locations transparently. This doesn't necessarily mean that disk space is used for swapping memory, it means, for example, that 5 processes can simultaneously be accessing address 0x5000, but the actual storage location is different for each. If the system (usually the page address translation facility on the CPU) determines that this address isn't at some location in volatile storage, it will bring in that memory from swap space and possible page out some other data. This is what the article is generally talking about.
I've seen some other questions about pages. There are a couple reasons for treating memory in page-size chunks, where a page is usually in the 1-8k range (4k for x86). First, the page address translation stuff needs to keep data on translations. It must do this in > 1 byte chunks, since keeping translation data on every byte would require way too much storage. Disk I/O and other I/O is frequently done on page-by-page basis for that reason as well as for the sake of performance.
Well, I rambled enough. Just wanted to clear a couple things up.
It's called "root" privileges. Thanks.
It is always amusing to me to read how M$ "invented" technologies that were in common use by other operating systems while Bill Gates was still wearing diapers. Both paging and swapping were used on IBM mainframes dating back to the mid 1960's. What windoze (and linux for that matter) could REALLY use is the ability to deterministically dedicate portions of system resources to particular processes.
Back when a 1 MIP, 1MB machine cost $1M, operators became highly skilled at managing workloads. Today everyone just throws oodles of RAM and disk at servers and lets the chips fall where they may , so to speak. It wouldn't be a bad idea to actually put a little thought into matching workloads with machine resources, and pro-actively matching them up by deliberate choice(For example - our company is running a prime-time ad at 9pm that features our URL, maybe that's a good time to shut down the normal file backup that happens then). Chaos theory is not always a good load balancer. But what am I saying, that's as outrageous as asking kids to put their money in the bank instead of buying video games...
"Sic Semper Path of Least Resistance"