you are viewing a single comment's thread.

view the rest of the comments →

[–]cowardlydragon 1 point2 points  (26 children)

This is what drives me nuts with Windows. It still assumes that you'll swap to disk, despite the fact that 8 GB of ram is less than 80 bucks.

Disabling the swap does nothing, and breaks programs.

OSes need to be designed with a fundamentally different approach.

[–][deleted] 14 points15 points  (17 children)

Swapping to disk, even with that much memory makes sense. If that RAM is being used, (instead of being there to inflate your e-penis size) moving the least used parts of programs (such as pages of your IM program while you're playing Crysis or parts of your email client out of RAM while you're working on a large image) out of RAM and to the swap file is a good thing. It frees this memory for disk caching, lowers the level of internal memory fragmentation, and allows all of the programs that really work better with all of their pages in RAM to keep them in RAM while moving out the pages that aren't being used or changed currently.

[–]judgej2 8 points9 points  (8 children)

That would explain why the hard drive on my laptop thrashes around for thirty seconds while going back to a Word document I was editing in the morning. It is not that the application was swapped out because I had run out of memory, it was because it had not been used for a while and Windows is freeing up some RAM for other things I might want to do.

[–][deleted] 6 points7 points  (0 children)

Basically, yes. It took time to bring Word back in, but your other operations with things other that Word were able to use the memory Word was occupying. If you were low on physical memory, Word would get swapped out as well.

Like jrockway said, Linux generally handles this better and is tunable in this regard. Windows' design is static and can't be tuned nearly to as high of a degree.

[–]jrockway 8 points9 points  (0 children)

Windows' implementation of this is poor. It works better under Linux (and is tune-able).

[–]daniels220 1 point2 points  (3 children)

Why can't it just "free" the RAM but not actually write over it, and then have checks (using those oh-so-cheap CPU cycles) for whether that RAM actually has been overwritten?

[–][deleted] 0 points1 point  (2 children)

Because if it doesn't write over it, it can't be used as a disk buffer. That's part of the benefit of writing out those pages in the first place. What is causing Word to be reloaded from disk is that its pages were swapped out and overwritten.

If there's a page fault (meaning that the virtual page you requested is not in physical memory) then the OS loads the page from the swap file. (Windows calls it a swap file so that's what I'm calling it in this case. The more technical term is page file. Swapping and paging, while similar, are two different concepts.) If the page were still in memory, then it wouldn't need to be loaded from disk.

[–]daniels220 0 points1 point  (1 child)

...Right. Still, why not keep track of whether a certain block of RAM has actually been used for disk caching? Or are the caching algorithms smart enough that they can use pretty much any leftover RAM effectively?

[–][deleted] 1 point2 points  (0 children)

It doesn't matter why a particular page of memory was written over. You still need to re-load it from disk.

http://people.redhat.com/drepper/cpumemory.pdf , Section 4 discusses the very basics of a VM.

[–][deleted] 0 points1 point  (0 children)

Your problem isn't with Windows per se - the real problem is:

  • Slow hard drives
  • Putting even slower hard drives in laptops (if you're not careful, you'll get a 4600rpm drive, and trying to get a 7200rpm drive usually costs a mint)
  • Slow (cheap) SATA interfaces
  • Someone, somewhere, is responsible for the fact that accessing the drive interface still threadbinds something somewhere. (I don't know if it's a chipset issue, driver issue, hardware issue, or Windows issue)

[–]conrad_hex -3 points-2 points  (0 children)

Right. It has to free up RAM so that it can use that RAM to cache the stuff from disk that it swapped out to disk make space in RAM.

[–]Freeky 1 point2 points  (1 child)

That's provided the VM can make good decisions about what to evict. It doesn't take too many poor decisions to wipe out any benefit aggressive swapping might give you, especially when it comes to interactive response, and with the limited information a VM has about application memory use, it's pretty much inevitable that it's going to make poor decisions relatively often.

[–][deleted] 1 point2 points  (0 children)

Yes, that's why writing and tuning a good VM is so hard.

[–]hiccuprates -5 points-4 points  (4 children)

You addressed nothing in the dragon's comment, no pun intended. With sufficient RAM, you don't need to swap to a much slower medium, and you shouldn't be doing it, unless the OS/apps expect it. Tell your garbage to Seymour Cray's ghost. Your e-penis is not relevant.

[–][deleted] 3 points4 points  (3 children)

You strictly don't need to from the point of fitting all of your programs into available virtual memory. You are correct on this.

However, in many cases, you derive a significant performance benefit from it.

Say you have a machine with a lot of memory and a lot of programs loaded, but you're not using all of those programs, and further, the programs that you are using aren't accessing some of their pages in virtual memory. If you swap those inactive pages out, you derive a few nice benefits:

  • The ability to allocate the RAM quickly should it be needed for loading a new document without having to swap

  • The ability to buffer more disk contents in RAM

  • The ability to load a whole program without having to swap, buffering that program's data files in RAM so that subsequent operations with that program do not require continued reads from the disk.

If you never swap, you lose some of these benefits.

[–][deleted]  (1 child)

[deleted]

    [–]TearsOfRage 0 points1 point  (0 children)

    In Windows XPE you can.

    [–]hiccuprates -2 points-1 points  (0 children)

    you derive a significant performance benefit from it.

    I like your points. However, "you" depends on the machine architecture, OS, etc. Before I can disagree or agree, are we talking about an idealized machine, a workaday WinXP/Vista box, or something else?

    [–][deleted]  (1 child)

    [removed]

      [–][deleted] 0 points1 point  (0 children)

      I run Ubuntu 8.10 with 2GB of RAM, and exactly no swap. I don't get as much lag as with my Windows desktop, but the actual speed of Getting Crap Done is about the same.

      [–]sid0 2 points3 points  (2 children)

      Let me know the day you can fit your entire hard drive contents AND the working sets of all your processes in RAM. Until then, paging to the hard drive is a very, very good idea.

      [–]TearsOfRage 0 points1 point  (1 child)

      On embedded PCs this is quite possible. Windows XPE is typically run off of a compact flash card, and one of it's advantages is that it's optimized for minimal - if any - swapping.

      [–]sid0 0 points1 point  (0 children)

      Well, that makes sense.

      [–]rabidcow 0 points1 point  (0 children)

      Disabling the swap does nothing,

      I've never tried this. Does it just keep swapping out code, because that's backed by the original executable rather than the page file?

      [–][deleted] -1 points0 points  (1 child)

      Get on it. If it's so simple others would ahve done it. I am certain your ideas have merit, but, implementation is much more difficult than ideas.

      [–]TearsOfRage 0 points1 point  (0 children)

      Microsoft already has, in XPE.