Slashdot Mirror


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."

36 of 495 comments (clear)

  1. Defrag first, man. by inertia187 · · Score: 4, Informative

    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.

    I've come across workstations where the paging file is in thousands of fragments. This happens when someone messes with the settings. For instance, they might increase the size of the paging file thinking it'll help to have more. Normally, it's not a bad idea to increase it but if the drive is heavily fragmented, Windows dutifully uses the fragments for the new space.

    The only way to fix it is to completely delete (deactivate) the page file, then do a defrag, then re-create the page file (several reboots involved).

    That's probably the best way to tune the page file. There, I saved you from having to take the time to read the article.

    --
    A programmer is a machine for converting coffee into code.
    1. Re:Defrag first, man. by UCFFool · · Score: 5, Insightful

      OMG, you mean you didn't read the article and possibly learn something?

      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 /. world.

      --
      "The more pity, that fools may not speak wisely what wise men do foolishly" - Touchstone,Shakespeare's "As You Like It"
    2. Re:Defrag first, man. by The+Snowman · · Score: 5, Interesting

      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!
    3. Re:Defrag first, man. by vp_development · · Score: 5, Funny
      ...She does not have Administrator privileges on my box...


      This seems unfair since I'm assuming you have admin privs on her box

    4. Re:Defrag first, man. by Clay+Pigeon+-TPF-VS- · · Score: 5, Funny

      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.
    5. Re:Defrag first, man. by dfn5 · · Score: 5, Funny
      What are you talking about?! Men never have admin privs on a woman's box.

      At least, not after marriage.

      --
      -- Thou hast strayed far from the path of the Avatar.
    6. Re:Defrag first, man. by blackmonday · · Score: 4, Funny

      Hey - That's better than her rights being set to "Everyone".

    7. Re:Defrag first, man. by the+unbeliever · · Score: 4, Funny

      Access to her box is on a per-request basis, most likely.

    8. Re:Defrag first, man. by The+Snowman · · Score: 4, Funny

      ...She does not have Administrator privileges on my box...

      This seems unfair since I'm assuming you have admin privs on her box

      No, I don't want admin privileges on her box. I don't want to have to deal with daily admin tasks. Instead, I am a power user. Oh yeeeeah!

      --
      24 beers in a case, 24 hours in a day. Coincidence? I think not!
    9. Re:Defrag first, man. by dzym · · Score: 5, Funny

      It's called "root" privileges. Thanks.

    10. Re:Defrag first, man. by Bloater · · Score: 4, Funny

      The real problem is where you get a nude sunbather, and they give you read-only access.

    11. Re:Defrag first, man. by mph · · Score: 4, Funny
      This has increased boot times on older computers running w2k by as much as 30 seconds.
      That's great! My machine's been booting too fast, and I've been looking for a way to make it take a half minute longer.
  2. Windows paging File... by demonbug · · Score: 4, Funny

    Would Mr. File please pick up one of the white courtesy phones? Your OS needs to talk to you.

    1. Re:Windows paging File... by k4_pacific · · Score: 5, Funny

      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.
  3. well.. by Anonymous Coward · · Score: 4, Funny

    They might want to adjust the paging file on their web server a bit...

  4. Slashdotted already? by cmburns69 · · Score: 4, Funny

    Given the speed of the slashdotting, I'd say he needs to add more ram to his box, and stop relying on the paging file for speed...

    --
    Online Starcraft RPG? At
    Dietary fiber is like asynchronous IO-- Non-blocking!
  5. FreeRAM by yuriismaster · · Score: 5, Informative

    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.

    1. Re:FreeRAM by finnhart · · Score: 4, Informative

      In the case of firefox, the application itself is responsible for getting out of RAM when minimized. I don't know what Mozilla you're running, but it may have the same behavior & fix.

      You can change the behavior by modifying the config.trim_on_minimize key (accessible via about:config). See http://windowssecrets.com/041202/) for more info on this.

      Makes a big difference - no more two second pauses when restoring firefox.

  6. not overly blessed with RAM by Tenebrious1 · · Score: 4, Funny

    ... for people who are not overly blessed with RAM.

    You mean those who's PHBs said the "minimum" requirements were good enough.

    --
    -- If god wanted me to have a sig, he'd have given me a sense of humor.
  7. Re:swap file vs. paging file by tijnbraun · · Score: 4, Informative

    As far as I know it doesn't...

    Here is some more info about paging and swapping under unix

    AFAIK a page is an group of memory addresses that are being changed/addressed at the same time.

    But I could be mistaken

  8. WTF by OverlordQ · · Score: 4, Funny

    It's 44 Pages!! I mean heck, the average /. doesn't read one page news stories, but a 44 Page Article!? Not in this lifetime.

    --
    Your hair look like poop, Bob! - Wanker.
    1. Re:WTF by halivar · · Score: 5, Funny

      Frankly, I'm impressed you even clicked on the link.

  9. One of the first paragraphs made me stop reading. by bigtallmofo · · Score: 4, Informative

    The site is so slashdotted that it took forever to load the first page which basically has nothing but useless history of swap files on it. Even the mirrordot doesn't appear to be working. Anyway, one sentence on that first page made me no longer interested in reading the article:

    Whenever the operating system has enough memory, it doesn't usually use virtual memory.

    This flies in the face of real world experience. You can have 4 gigs of RAM and nothing but Windows 2000 running and your OS will still use the swap file frequently. Don't believe me? Run Performance Monitor and monitor Memory, Pages/Sec and just click on a few things and you'll see that I'm correct.

    --
    I'm a big tall mofo.
  10. Does he really believe this? by Peaker · · Score: 4, Insightful

    The solution they came up with was to use some space on the hard disk as extra RAM. Although the hard disk is much slower than RAM, it is also much cheaper and users always have a lot more hard disk space than RAM. So, Windows was designed to create this pseudo-RAM or in Microsoft's terms - Virtual Memory, to make up for the shortfall in RAM when running memory-intensive programs.

    Amazing how they manage to turn everything around as though Microsoft invented the world of computing...

    Virtual memory, the term and the implementation have been around long before Microsoft came into existence.

    1. Re:Does he really believe this? by pchan- · · Score: 4, Informative

      In fact, what he is describing is NOT virtual memory, but demand paging. At this point, I stopped reading the article.

      Virtual memory is the mapping of physical memory pages to a "virtual" memory address using hardware translation tables. This is done so that every application lives in its own private memory space, and cannot interfere with other applications' memory (or the OS's). Basically, this technique of memory isolation keeps user apps from crashing the system or other applications. Virtual memory support has been added to x86 with the release of the 80386 processors and 32-bit flat memory addressing. Of course, virtual memory has been available for years before this on such OS's as DEC's VMS (the Virtual Memory System), IBM's MVS, UNIX, and a bunch of other systems I'm too young to know about.

      The misnaming of demand paging was actually started by Apple (continuing their tradition of calling the box a "CPU") for their swap file management (long before MacOS's support for VM in OSX).

  11. CAUTION: Ignorant Article Writer detected by DrZiplok · · Score: 5, Informative

    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

  12. Re:Or by XorNand · · Score: 5, Informative

    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"
  13. Re:swap file vs. paging file by Alioth · · Score: 5, Informative

    Well, since you've had four incorrect and or unhelpful responses so far, let me shed some light:

    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 /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:

    echo 40 >/proc/sys/vm/swappiness

    Most 2.6-based distros have some GUI tool that can tweak parameters like this (Fedora certainly does).

  14. article still doesn't address misconceptions by Anonymous Coward · · Score: 5, Informative

    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.

  15. Another link to article by SailFly · · Score: 4, Informative

    I found this link to the article: Swapfile_Optimization

  16. 44 pages long, full of "sponsored links" by snorklewacker · · Score: 4, Insightful

    Putting http://text.burstnet.com/* into adblock makes for a slightly less annoying experience, but there's also the fact that it's 44 freaking pages long. Probably getting paid by the site hit or something.

    Do yourself a favor, give this content-lite article a miss. Make a small partition with ntfsresize, put a fixed pagefile on that partition alone. Works on every single version of windows and it's zero maintenance. Tah-dah.

    --
    I am no longer wasting my time with slashdot
  17. MS invented everything by couch_warrior · · Score: 5, Interesting

    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"
  18. Re:Before the defrag by Henk+Poley · · Score: 4, Informative

    I've mentioned it elsewhere already. But try PageDefrag and Buzzsaw.

    The first one will defragment your Windows pagefile on each boot. And Buzzsaw will defragment recently accessed files in the background, much less intrusive than Diskkeeper. Both are freeware tools.

  19. Re:swap file vs. paging file by TiggertheMad · · Score: 4, Funny

    To change the swappiness, say, to 40:

    You sir, are the coolerist. It sweets up the language to add colorfulistic verbing and adverbly structures like the one you buildily made aboverness.

    Rockeringly on, dude!

    --

    HA! I just wasted some of your bandwidth with a frivolous sig!
  20. Re:corrupt by tomhudson · · Score: 4, Informative
    It seems like Linux needs a paging file instead of swap partitions to become more responsive and more ready for the desktop.
    Don't bother - the article is full of inaccuracies.

    For example, even under Windows 3.1, the swap file only swapped in chunks of 4/8k. It's just that, on machines that were memory-poor (like we all were way back when), most users had their boxes configured with a 3/1 ratio of swap to real ram, and most of their free real ram then ended up being used to manage the swap file. 2/1 was the sweet spot.

    The DOS Shell program, on the other hand, worked by swapping out whole processes, allowing DOS 5.0 and up to appear to multitask.

    Pick up a copy of any decent assembler manual for the 2/386 from the early '90s, look for the instructions for swapping pages into ram. It's a hardware function. On a page fault, the cpu then goes through a look-aside buffer (8k worth of pointers each, IIRC, local and global), and then you can map pages of ram in/out as required. Just don't triple-fault, as the cpu would then go out of "enhanced" mode and/or reboot.

    Must be a REALLY SLOW day for this to be "news".

  21. Who needs a page file by GAATTC · · Score: 4, Funny

    Who needs a page file when you have a 10.00 GHz AMD Athlon, a 2000 MB DIMM, and a 30000 GB IDE Hard Disk http://www.amazon.com/exec/obidos/tg/detail/-/B000 22ACYK I quote from a review: "I was a little skeptical at first on how this thing would perform. However, when I installed and run the Seti@home program it started instantly finding alien signals, which where corrected, cleaned up and translated. I am now listening and talking to the supreme galactic defense minister about Earths surrender. Apparently this computer is not only tapping into the sun for power but also into the mysterious dark energy and tearing the universe apart. Just comes to show how bugs always show up in technology when you least expect it."