Slashdot Mirror


Is Swap Necessary?

johnnyb writes "Kernel Trap has a great conversation on swap, whether it's necessary, why swapless systems might seem faster, and an overall discussion of swap issues in modern computing. This is often an issue for system administrators, and this is a great set of posts about the issue."

581 comments

  1. IMHO by rd4tech · · Score: 3, Interesting

    One can have 1GB of RAM for a fairly cheap price.
    I really doubt that majority of newest desktop PCs need to swap on the HD at all.

    The unused/used portions argument from the article isn't quite true. You don't have to swap every unused bit,
    if you have enough RAM, leave everything there. It's R-A-M. don't access parts you don't need.
    If you don't have them in the RAM, read them from the drive,
    don't waste time putting them where they mostly are in the first place.

    I'm willing to bet that people who need performance, don't often run 10 applications at the same time. If they do, they
    surely know what are they doing.

    IMHO the average user should get enough RAM and no swap, let the OS optimize things a bit.

    1. Re:IMHO by Trepalium · · Score: 5, Interesting
      The other side of this is that memory that is not being used is wasted. Getting unused memory out of RAM, and into swap, so that memory can be used for real work can improve performance. This isn't just about memory that your applications are using. It's also about memory that is being used as cache for the disks you're using.

      Maybe you have enough memory to run your program, but you don't have enough memory to keep enough directory structures into RAM, so you keep needing to read the disk. If there are unused pages in that program that were only used once during startup, for example, it makes sense to get them out or memory, so that memory can be used for disk caching instead.

      Now, you have to understand how Linux handles paging, too. Unmodified pages from executables that are running may be discarded by the kernel at any time, because it knows where to get them. They won't be thrown into swap because it's not necessary. On the other hand, if that particular page has been modified (and some are modified as they are loaded by ld.so, for example), then the page must be copied into swap before it's discarded.

      --
      I used up all my sick days, so I'm calling in dead.
    2. Re:IMHO by irokitt · · Score: 5, Informative

      Linux has two properties that make swap a good thing (TM).

      The first thing to remember is that, for many Linux users, they have a newer PC running Windows (or a Mac ;) and a less recent PC running a Linux distro. The RAM threshold is realistically around the 128-512 MB range. Those who are dual-booting on a brand new machine can use 1 GB, but the rest of us put up with less than that (I for one want to avoid MBR screwups and the hassle of communicating with NTFS, so I don't dual boot. I had a nasty GRUB incident, so I'm probably paranoid).

      Finally, every Linux user that has compiled a kernel knows that it can really tax a system. Gentoo users also know how strenuous a XFree86 or KDE/Gnome compile can be. Being able to work on another terminal while compiling is one of the most beautiful things about *nix, and to do that on anything with less than 512 MB or 1 GB or RAM you want to have some swap.

      And finally, while RAM is very cheap, so are hard drives, and how hard is it to squeeze a swap partition out of a hard drive? Can it really hurt that much to let the system use it?

      As for Windows, swap is absolutely required for a lot of the games that are out there. I've heard that Unreal-engine based games in particular make heavy use of swap filing.

      --
      If my answers frighten you, stop asking scary questions.
    3. Re:IMHO by jrockway · · Score: 1

      I have 1G of RAM, and no swap. Works great, even with eclipse, maple, firefox, and other stuff open at once. Having 10 things open at once doesn't degrade performance under Linux. That's a feature reserved for Windows...

      --
      My other car is first.
    4. Re:IMHO by zoloto · · Score: 4, Informative

      My take on the swap -vs- no swap.
      I have no data, links or proof to back it up. Only the system responsiveness under two different setups.

      Setup A) 300mhz intel, 256mb ram, 6gb hdd, swap 512mb.
      Taking the swap out of that setup and the system crawled to a halt, expecially when using X. Re-enabling it and it ran just fine.

      Setup B) 2GHz Intel, 1gb ram, 40gb hdd, swap 2gb.
      Taking out the swap in that machine and the system ran fine. Even running Half-Life: Counter-Strike via WineX by transgaming. Re-enabling the swap, and I noticed a little performance increase, but I couldn't measure it b/c I didn't know how.

      Just my take on it. Swap is generally a good thing in older machines, while in newer systems it isn't a critical thing to have. HOWEVER, I did not run many tests with and w/o swap. just basic use, and Setup B's HL:CS test was only to make sure!

      YYMV, KBD.

      -zoloto

    5. Re: IMHO by Black+Parrot · · Score: 2, Insightful


      > Linux has two properties that make swap a good thing (TM).

      A third: Linux is a powerful and stable tool that makes it possible to run a dozen virtual desktops and stay logged on for a year at a time. So if you're a power user who leaves scores of applications open indefinitely as part of your ongoing work, kick some of them out to swap and leave them there until you get back on that project.

      I've added first one and then a second swap file, to quadruple the size of the swap partition I made when I installed my current system. My next system will have much more memory, but much more swap space as well. I'll just leave more and bigger programs open on more virtual desktops, and run less risk of The GIMP blowing up when I run a complex fu script on a big image.

      --
      Sheesh, evil *and* a jerk. -- Jade
    6. Re:IMHO by DrEldarion · · Score: 1

      I have 1G of RAM and no swap. Works great, even with IE, winamp, AIM, DC++, bittorrent, and other stuff open at once. Having 10 things open at once doesn't degrade performance under WinXP, either, with any respectable computer.

    7. Re:IMHO by Snowmit · · Score: 1

      If you don't have them in the RAM, read them from the drive, don't waste time putting them where they mostly are in the first place.

      Hold on a sec. A compressed file on my hard drive looks very different from its uncompressed instance that's been decoded and loaded into memory. Storing the decompressed "RAM version" of the file on HDD and then loading it into RAM as needed would be faster than decoding the file all over again, no? Less processor intensive for sure.

      --
      I have a lot of opinions about Cyborgs and Architects
    8. Re:IMHO by CAIMLAS · · Score: 4, Informative

      Kernel compiles do -not- tax the system. They utilize it. There are relatively few process threads used during a kernel build, substantial CPU use per process, a fair amount of disk reading, and a large amount of memory swapping about and modification.

      Its perfectly reasonable to expect a system to be responsive while compiling a large project. That's not a "taxed" system. A slashdotted machine, which spawns thousands of apache processes, is taxed, however.

      Except for your statement that for "anything less than 512M or 1G of RAM you want to have some swap"... You want to have swap all the time, unless there's a power-related (ie, laptop) reason to not have it. As the article says, it's trivially demonstrated that there is a performance increase by using swap, regardless of how much RAM. It is, however, imperative to have swap if the machine doesn't have much ram, otherwise you'll run into some nasty results after a while. :)

      I'd agree with your last two sentiments. :)

      --
      ~/ssh slashdot.org ssh: connect to host slashdot.org port 22: too many beers
    9. Re:IMHO by Ark42 · · Score: 1

      I have 1G of RAM and tried no swap, and tried only 128M of swap, but Windows 2000 keeps insisting that I am running out of virtual memory and it needs to increase the size of the paging file? Why does it do that? I told it the min and max size are the same. I upped min and max to 256M but still got that warning all the time. Now my swap file is fixed at 512M and I havn't seen the error recently, but who knows?
      My peak commit charge according to task manager hasn't hit 1G yet, so nothing I've had open in the 363:03:17 amount of time that the system idle process has clocked in so far has ever made me need more RAM that I have, right? I think Windows 2000 is just flawed. I shouldn't really NEED swap, but windows is just happier having it. I guess windows just really needs that 811516 Kbytes of "System Cache" it has right now.

    10. Re:IMHO by PacoTaco · · Score: 2, Insightful
      Finally, every Linux user that has compiled a kernel knows that it can really tax a system. Gentoo users also know how strenuous a XFree86 or KDE/Gnome compile can be.

      It shouldn't be, unless you have a low memory system and everything (including your swap) is on an older IDE disk that doesn't seek quickly. I often leave large builds running in the background on Windows, BSD and Linux systems with no noticeable impact on system responsiveness.

    11. Re:IMHO by Anonymous Coward · · Score: 0

      wow.

      you just proved that if you are close to the threshold and you start _seriously_ hitting the page file, that your system will slow down.

      nobel peace prize anyone?

    12. Re:IMHO by origin2k · · Score: 1

      "Memory is like an orgasm. It's a lot better if you don't have to fake it."

      -Seymour Cray

      ICMP: The protocol that goes PING!

    13. Re:IMHO by Anonymous Coward · · Score: 1, Insightful

      I agree that systems with constraints on RAM need to have space for disk caching, etc... but there is a problem with how this is all implemented on the two dominant OS options (Wxxx and Linux). Both systems are tuned to assume RAM is inadequate, even though this is no longer common in newer systems. For example, on my primary dev system the OS swaps out 30M of data to swap, then allocates 750M for disk cache, and a quick run through the cache buffers with a debugging tool shows that the entire swap file is in the disk cache, along with 400M of unused disk cache, and about 300M of other data, 95% of which is marked stale (meaning the system has to reread it on next access anyway). This leaves me in the strange position of having the OS swapping much of itself out to slow disk, then using RAM to cache the entire swap file to improve performance. I don't have any choice in the matter. Swap is fine, but only if we can put something resembling an intelligent algorithm in there to ensure that swap is only used if, and when, it's really needed.

    14. Re:IMHO by Wolfrider · · Score: 1

      > You want to have swap all the time, unless there's a power-related (ie, laptop) reason to not have it.

      --Actually, IIRC the Linux suspend-to-disk function, which is used mostly for laptops (swsusp; and there's an alternate implementation as well) requires at least swapspace == amount of installed RAM to work properly.

      --I recommend at least 512MB RAM for any modern Linux desktop system these days, if you intend on using KDE or Gnome, or for any "serious" work. Depending on intended regular usage however, you can prolly get away with ~64MB of swap as a lower limit (I really wouldn't recommend anything *less* than 32MB swap tho as a rule-of-thumb; modern HD's these days can read all that out in less than 2 seconds) but as always, test your specific system for what works best for you.

      --
      .
      == WolfriderV6 == I'm willing to admit that *I just might* be wrong... Are you??
    15. Re:IMHO by Amorpheus_MMS · · Score: 3, Interesting

      Setup B) 2GHz Intel, 1gb ram, 40gb hdd, swap 2gb.
      Taking out the swap in that machine and the system ran fine. Even running Half-Life: Counter-Strike via WineX by transgaming.


      Do try that with Far Cry, I'm curious whether you'll notice a difference there. That recommends 1GB RAM, and swapping unused memory is certainly considered.

      Personally, I think games are the one reason why swap is still very useful. You either run your programs on your desktop, or a game - not both. Getting enough RAM to hold everything is wasted money.

    16. Re:IMHO by XaXXon · · Score: 1

      As the article says, it's trivially demonstrated that there is a performance increase by using swap, regardless of how much RAM

      I don't think you're interpretting the comment properly..

      It is trivial to demonstrate the best case scenario for swap -- the case that makes a system with swap better, but not for ALL cases. The case where swap is good is when you have some amount of RAM, and a process that is using a large portion of it. Say this process hasn't been active in a week. You run another process -- you're grepping through a large source tree -- larger than the amount of RAM left over after this week-old large process. By dumping this old application out to swap, the source tree is then cached and subsequent greps are virtually instant, requiring no disk access.

      This is *FAR* different from being trivially demonstrated that by using swap you always get a performance increase. The above mentioned situation, can easily backfire. If you only wanted to do that grep once, and that was the information you needed to get back to your old program, then you're going to dump the program out to ram (disk write), read the source tree in and store it to ram (disk read), and then load your program back into memory (disk read). That's 3 disk accesses. On a system with no swap, you would read the files in, grep them, and immediately discard the information from the file -- resulting in 1 disk read.

      This is just to say that it's also trivial to demonstrate a situation where swap is bad.

    17. Re:IMHO by EsbenMoseHansen · · Score: 4, Informative
      That sounds seriusly broken to me. My linuxboxen never swap before the entire RAM is filled (with cache or otherwise). Even so, the swappiness stays quite low. Perhaps you show turn the
      /proc/sys/vm/swappiness
      knob down a bit? Or perhaps use this patch.
      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    18. Re:IMHO by Laebshade · · Score: 1

      Being able to work on another terminal while compiling is one of the most beautiful things about *nix, and to do that on anything with less than 512 MB or 1 GB or RAM you want to have some swap.

      I really hope that wasn't you saying that. 1 GB of RAM is nice, yes, but the fact that you said it was required to be able to compile and use a terminal is quite funny. So if I open another terminal, I should put in some more RAM? 128mb, 256mb, or 512mb? Maybe just another gig for good measure?

    19. Re:IMHO by maraist · · Score: 2, Insightful

      I can't confirm the details, but it was my understanding that the Alan Cox fork in RedHat 9 had an implementation where the swap had to be at LEAST as big as main memory.. Theoretically the reason is that you preform pre-swapping.. The idea is that if you waited until the last second to do any swapping, then your most efficient choice would be to swap non-dirty pages.. but if instead during idle periods of IO you swap dirty pages, then when it comes time to swap, just about everything is fair game, and you can truely swap out the LRU pages with great efficiency.

      Thus you'd pre-swap once you got to like 60% full memory.

      More-over, as others' have said, unless you have as much RAM as the average hard-disk space used / day, then you are in a non-optimal operating environment, since your cache isn't as big as it should be.. cache flushing swapping.. They're almost identical in user-time experience (though aruably, re-reading a contiugous chunk of file-data is going to be faster than unswapping randomly positioned data; but how many files are contiguous these days?).

      Thus if you have a daemon with a LOT of setup code which is never used again after startup, then it makes sense to permanently swap this out to disk to free up space for the cache.

      --
      -Michael
    20. Re:IMHO by Jeff+DeMaagd · · Score: 2, Interesting

      I'm sick of the speculation. Maybe Linux has some key benefits that make swap useful on a machine that has more memory than it needs to operate. I'd like to see some evidence that those techniques actually make a jack of a difference or not.

      Is there anyone willing to take two identical machines and run a full Gentoo compile, with or without swap, with 256, 512 and 1028MB RAM installed, and time it? If swap really does make a difference, I think that sort of thing would help tell when swap is or is not useful in currently available systems. I'd love to do it but I simply don't have a good internet connection to do it.

    21. Re:IMHO by CmdrTHAC0 · · Score: 1

      "A compressed file on my hard drive looks very different from its uncompressed instance that's been decoded and loaded into memory."

      You're using a compressed filesystem? Where do I get one of those? It'd sure be handy for backups...

      --
      __CmdrTHAC0__
      In Soviet Russia, Spanish Inquisition doesn't expect YOU!!
    22. Re:IMHO by Jeff+DeMaagd · · Score: 1

      Oops, for the pedants, yes, the RAM amount should be 1024MB. Too bad that Slash is one of the few forum programs that doesn't allow post editing.

    23. Re:IMHO by Zzootnik · · Score: 1

      That reminds me of something... YEARS ago when I was running win98, I also used this small utility called MemTurbo. Basically, it de-fragged your active memory and cleared up a lot of the flotsam and what not that was still lingering in active memory, but no longer needed or asked for. It had a manually run mode and a 'trigger-point' mode, where if your memory usage went up to a certain percentage, it auto-ran and cleaned up unnecessary stuff. Probably flushed any cache as well...

      If we had something like this, (maybe even as a kernel module?) It would probably at least be a decent tool for eliminating or delaying disk-swaps... Run it on a cron job or as-needed.

      I'm thinking this might be a very cool little project to write if it hasn't been written already (Or isn't even feasible...???)) Time to do some googling I guess...

      --
      Sig currently under construction. Mind the gap....
    24. Re:IMHO by Anonymous Coward · · Score: 0

      Clearly sir, you do not use Windows NT based systems very often.

      There is an unwritten law concerning these systems.

      "The size of virtual memory needed by NT/2000/XP systems, doubles for every MS Office upgrade cycle."

      I now have 1GB of RAM. It still swaps out. And once NT swaps out, it won't swap back in again. And It hates the swap its already used so It has to find new space every time you open a new program, leading to "uptime drag". If you leave any NT machine on for long enough, even if you close programs, it will run out of HDD space with which to swap. That's why they must be rebooted so often. And you thought it was because of registry issues!

      Remember Troubleshooting:ch7,v13-14 :
      "And Redmond said unto them ; 'Thou shalt not manage Virtual memory settings manually, for he that does so shall recieve only out of memory errors as his reward'. And so it was agreed, that the disk should thereafter be the brother of RAM in the eyes of the Kernel, and that none should mention the darkness the DOS foundation..... which of course wasn't there anyway... having been removed in 95... actually 3.11 .... before 98SE anyway."

      And yes I know Linux doen't have these issues ,and I should migrate fully but consider

      Compatability: ch14, v27-34;

      "And the son return to the father, broken and bent from his exertions and he did weep and sue for pardon saying , 'Forgive my rashness, my Lord, for had I but known of the barren desert of the Unix framework I should never have lost my faith.' And Gates did smile and say unto him , 'My son, I knew of all your troubles before you felt them. Know now that I have given you, OLE, MFC, COM+, VBA, and NTFS for your comfort and convienience only, and that by casting me aside, you spite only your own productivity and development cycles. Come now and see what I have prepared for you.' And they did make haste to Redmond and there saw all the fruits of wonder that were there prepared; .Net framework, VB.NET , C#, ASP.NET, win-FS, XAML and countless other wonders. And in the midst of all this the long horned cow grazed happily on the green acres of the XP margins. And the son did marvel and say , 'Truely, how can I ever think to leave this garden'. And the Linux unbelievers did wail and baSH their teeth."

      Now do you see why Linux migration is so difficult. It's all there in the windows helpfiles. You just have to look.

    25. Re:IMHO by electrofreak · · Score: 0

      Kernel compiles do -not- tax the system. They utilize it.

      It does if you do this:

      $ make -j


      I think that swap is very necessary. While it may not allways be needed, it is good to be there so when something starts memory leaking, the swap file is there to give you... more time to see about stoping it. And yes, when playing games, swap is a must. Especially if you are like me, who currently has 33 mozilla windows open, 15 console windows, xmms, gimp2, 3 openoffice's, ...etc. The list goes on, but I'm not going to close everything i'm working on to play a game. I just open the game. Linux knows what to do. And the game runs just fine on my system with 512 MB of RAM, and a 4GB swap.

      --
      I need a sig.
    26. Re:IMHO by swv3752 · · Score: 1

      My 366 Celeron Notebook only has 192mb of ram yet under most circumstances I can safely disable swap. I have a 128mb swap space that usually gets unused.

      My 1.74Ghz desktop consistently uses 1mb of swap.

      --
      Just a Tuna in the Sea of Life
    27. Re:IMHO by Snowmit · · Score: 1

      No, compressed files. Files that need to be decoded when they're loaded into memory. MP3, JPEG, etc. etc.

      Most files takle up more RAM than they take up disk space.

      --
      I have a lot of opinions about Cyborgs and Architects
    28. Re:IMHO by jguthrie · · Score: 1

      If it's so easy to demonstrate that swap will always improve the performance of a system, then why has no one made that demonstration? In fact, I haven't seen any demonstration that suggests that it is better to have 256M of semiconductor memory plus 256M of swap than 512M of semiconductor memory with no swap. Why is it so much harder to grep the kernel tree if there is an application resident in RAM that would have long since been swapped out to disk on a system with a lesser amount of RAM?

    29. Re:IMHO by RatRagout · · Score: 1

      I *really* think this i something the operating system should do by itself... And they probably do... except windows98 which is made of duplo lego.

    30. Re:IMHO by Phydoux · · Score: 1


      I'm still waiting for the patch that will allow me to set my swappiness level to 11.

      --
      If a tree fell on a florist, and nobody was around to hear it, would he make a noise?
    31. Re:IMHO by afidel · · Score: 1

      Under windows this behavior can be avoided by enabling the DisablePagingExecutive registry key. At the consultancy where I work we do this to all machines with >=512MB or RAM including all servers. This keeps them from swapping the kernel during extreme situations which often means we can recover from runaway processes.

      --
      There are 4 boxes to use in the defense of liberty: soap, ballot, jury, ammo. Use in that order. Starting now.
    32. Re:IMHO by 10Ghz · · Score: 1

      FYI: the amount of swap does not have to be double the amount of RAM. It used to be like that, but it hasn't been so in years.

      --
      Lesbian Nazi Hookers Abducted by UFOs and Forced Into Weight Loss Programs - -all next week on Town Talk.
    33. Re:IMHO by CmdrTHAC0 · · Score: 1

      Oh, I see. You're talking about applications' spaces instead of pagecache.

      --
      __CmdrTHAC0__
      In Soviet Russia, Spanish Inquisition doesn't expect YOU!!
    34. Re:IMHO by devilspgd · · Score: 1

      Xince we're discussing swap vs performance, only change the swap, don't go tweaking other aspects of the system at the same time as reporting back about the swap's effect on performance.

      It should be obvious to even the most dimwitted /. reader that if you increase RAM from 256MB to 512MB then you increase performance (where the system was swapping at 256MB, or where that additional RAM can go to a disk cache)

      A more interesting question would be at 512MB RAM, does setting swap to 0MB/256MB/512MB make a difference.

      When 512MB/0MB vs 256MB/256MB, it should be obvious that 512MB/0MB is better, since you're making the same amount of memory available to the system, and you're increasing the average speed of the memory. However, 512MB/256MB would be better then either of the above.

      --
      Give a man a fish, he'll eat for a day, but teach a man to phish...
    35. Re:IMHO by EsbenMoseHansen · · Score: 1

      I'm probably too tired to see the joke, but in the 2.6.x series, you can set it to any value between 0 and 100...?!

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    36. Re:IMHO by Anonymous Coward · · Score: 0

      http://e2compr.sourceforge.net/ (Compressed ext2 read/write)

      There are many others, but read-only.

    37. Re:IMHO by Trepalium · · Score: 1

      I believe most of those programs just did a very large allocation of memory, which basically forced Windows 98 to start cleaning up to make room for this large memory chunk that was requested. In a way, Windows 98 was too lazy with it's swap and memory allocation duties, and the problem with Linux is it's too dutiful for some workloads. Windows 98 wasn't swapping out when it ought to, and Linux is swapping when it shouldn't. The problem for Linux users is more a matter of tuning than anything else. Sysadmins like having knobs they can turn, and Linux only provides one -- swappiness (and what exactly it changes is a little unclear to most people, myself included).

      --
      I used up all my sick days, so I'm calling in dead.
    38. Re:IMHO by AltaMannen · · Score: 1

      I think 1GB should be enough for any system running a compiler not to swap (with windows in the background) but no, the system keeps swapping a lot during this process. The problem with the OS swapping during compiling is that with all the preprocessing and headerfiles the harddrive is used as much as the CPU so the CPU has to wait for the OS to swap something so it can read/write something it has just processed.

    39. Re:IMHO by Anonymous Coward · · Score: 0

      His older system slowed down when the swap was off, dumbass.

  2. Swap is definitely necessary by betterthanducttape · · Score: 3, Insightful

    When I was running Linux on my 350 mHz Pentium II with 128MB RAM, you can dang well bet I wouldn't have made it without a swap partition. I probably would have gone back to Windows if swap hadn't existed.

    1. Re:Swap is definitely necessary by Anonymous Coward · · Score: 2, Interesting

      Not for everyone. I've got 1GB in my machine, and I don't think I've ever come near maxing it out. I've actually turned off the pagefile* in Windows and haven't had any problems other than Photoshop whining everytime I start it (even if it never uses more than 100MB of RAM, it still whines if there's no pagefile present).
      I don't use linux, so I can't say how well it'd work on my machine without swap, but I can't imagine it'd be any worse.

      * For the Windows-ignorant: a pagefile is the Windows equivelent of swap.

    2. Re:Swap is definitely necessary by user32.ExitWindowsEx · · Score: 1

      Wait...you got Photoshop to actually RUN?

      I tried it and I don't remember getting it to actually run..it would whine about no swap file and the error box about no swapfile would basically quit the prog

      --
      "Evil will always triumph because good is dumb." -- Dark Helmet
    3. Re:Swap is definitely necessary by irokitt · · Score: 1

      Yeah, it's really just a swap file. You can do the same thing in Linux, which allows you to avoid partitioning your hard drive and also allows you to adjust swap size on the fly.

      I still use a page file because you need it for gaming. In fact, I heard somewhere that there are games that freak if you don't have a larg page file, even if you have more than enough RAM to do without. Kinda like a security blanket...

      --
      If my answers frighten you, stop asking scary questions.
    4. Re:Swap is definitely necessary by Anonymous Coward · · Score: 0

      For me it brings up a dialog explaining the sins of not having a pagefile. At the end is asks if you want to continue launching Photoshop. Click no, and it quits. Click yes, it goes ahead and starts normally. Just don't run a bunch of filters on 2000x3000 images or anything. :)

    5. Re:Swap is definitely necessary by Anonymous Coward · · Score: 0

      Really... I didn't know that. I don't do much gaming though. Battlefield 1942 works, although it does take up a good 5-600 MB.

    6. Re:Swap is definitely necessary by silicon+not+in+the+v · · Score: 1
      Yeah, it's really just a swap file. You can do the same thing in Linux, which allows you to avoid partitioning your hard drive and also allows you to adjust swap size on the fly.
      That is what I have been looking for. I didn't know that Linux could do with a swap file instead of partition. I have an 8.4GB drive dual booting with Win98, so space is a little tight. My question is now, will most distros do a page file automatically if you don't set up a swap partition?
      --
      We may experience some slight turbulence and then...explode. -Capt. Mal Reynolds
  3. If You have enough RAM by Greyfox · · Score: 5, Funny

    You could make a big ramdisk and swap to that!

    --

    I'm trying to teach myself to set people on fire with my mind... Is it hot in here?

    1. Re:If You have enough RAM by whiteranger99x · · Score: 5, Funny

      Yeah, just remember to allocate twice the amount of ram that you have installed! :)

      --
      Join the TWIT army now!
    2. Re:If You have enough RAM by Anonymous Coward · · Score: 0

      I have often wondered about this, is this a valid approach??

    3. Re:If You have enough RAM by josh3736 · · Score: 1
      You could make a big ramdisk and swap to that!
      I have often wondered about this, is this a valid approach??

      No.

      By definition, a RAM disk is kept in RAM. Therefore, you'd be swapping out of RAM... into RAM. It's the same as if you would put a divider in a storage shed because you were running out of room. You can move stuff on either side of it, but in the end, you still only have a fixed amount of space.

    4. Re:If You have enough RAM by machacker · · Score: 1

      ive thought of this before but never tried it. its the best of both worlds, speed of ram and the advantages of swap

    5. Re:If You have enough RAM by arekq · · Score: 1
      It is an approach that won't do you any good.

      Think about it: Amount of RAM stays constant. Instead of just leaving the data where they are, you waste some cpu cycles moving them to another part of the memory space...

    6. Re:If You have enough RAM by arekq · · Score: 1
      Are you serious?

      The advantage of swap is that it increases the amount of memory applications can use without adding more RAM.

      If you use RAM disk for swap, it'll only decrease performance because of the unnecessary moving of memory blocks.

    7. Re:If You have enough RAM by Anonymous Coward · · Score: 1, Interesting

      This might not be such a funny comment considering that why they swap improves performance is

      "well it is a magical property of swap space, because extra RAM doesn't allow you to replace unused memory with often used memory. The theory holds true no matter how much RAM you have. Swap can improve performance. It can be trivially demonstrated."

      Wouldn't having a swap drive in ram improve the overall performance of having a swap drive and still keep the above true?

    8. Re:If You have enough RAM by Anonymous Coward · · Score: 0

      I know one person that is quite good at tweaking MS Windows that actually claims this can be a good idea.

      On a related note, back in the late System 7, early Mac OS 8 days, I used to create a RAM disk to use as my Netscape cache. It resulted in a HUGE increase in speed when surfing on an 8500/180.

    9. Re:If You have enough RAM by Anonymous Coward · · Score: 0

      but supposdly there are technical differences in the way the os handles memory between ram and hd besides speed. i would like to see some actuall tests comparing for example:

      256 ram + no swap

      128 ram + 128 ramdisk as swap

      128 ram + 128 swap

    10. Re:If You have enough RAM by Wog · · Score: 2, Insightful

      I think what he's attempting to solve is the problem of some apps throwing a fit when they can't find a bunch of swap space, regardless of the 4 gigs of RAM installed...

    11. Re:If You have enough RAM by CerebusUS · · Score: 1

      You could make a big ramdisk and swap to that!

      I have often wondered about this, is this a valid approach??

      No.

      By definition, a RAM disk is kept in RAM. Therefore, you'd be swapping out of RAM... into RAM. It's the same as if you would put a divider in a storage shed because you were running out of room. You can move stuff on either side of it, but in the end, you still only have a fixed amount of space.


      Surely you can mark certain pages as "non-pagable," right? (I'm not a linux guru, so I really am interested in the answer to that question)

      If so, set up about 256MB as non-pagable, run a ramdisk mounted as /swp, and go to town with 768MB left over in userspace.

    12. Re:If You have enough RAM by whiteranger99x · · Score: 1

      By definition, a RAM disk is kept in RAM. Therefore, you'd be swapping out of RAM... into RAM. It's the same as if you would put a divider in a storage shed because you were running out of room. You can move stuff on either side of it, but in the end, you still only have a fixed amount of space.

      Except that the original poster was saying that in a case scenario, he might have enough ram to spare for a ramdisk. For example, if he has 1GB of ram installed and allocated 256MB for the ram disk, he would still have 768MB of RAM, not too shabby. However, I will agree with you and your parent poster as far as questioning whether it'll do any good in practice.

      --
      Join the TWIT army now!
    13. Re:If You have enough RAM by gerardrj · · Score: 1

      Working at the Apple call center in the era of the Performas, I had a caller that was complaining their computer was really slow and making a lot of grinding noises.

      Turns out in a system with like 16MB of RAM, they'd enabled Virtual Memory for something like 128MB, and then created a RAM disk of 92MB to which the OS was installed and booted.

      I don't think the caller ever understood just what the problem was, but we got everything saved and booted to the HD and things were normal again.

      --
      Article X: The powers not delegated... by the Constitution...are reserved...to the people
    14. Re:If You have enough RAM by Anonymous Coward · · Score: 0

      No, if the second setup ended up winning anything it would indicate terrible failure of the memory manager.

      You obviously want all your RAM to be used as often as possible.

      Swap, being orders of magnitude slower than RAM when used correctly (ie on disks), needs to be used sparingly, and only when it is absolutely nessecary or to swap out memory that isn't being used.

      Now the swap-ramdisk setup will obviously be faster than the swap-disk setup because you are essentially replacing a slower component of the system with a faster one, however it will cause the 128MB of RAM in the swap device to be used only very reluctantly. What a waste!

    15. Re:If You have enough RAM by base_chakra · · Score: 1

      By definition, a RAM disk is kept in RAM. Therefore, you'd be swapping out of RAM... into RAM. It's the same as if you would put a divider in a storage shed because you were running out of room. You can move stuff on either side of it, but in the end, you still only have a fixed amount of space.

      I realize that on the surface this seems like an intuitive assumption, but it's empirically unfounded and incorrent. Swap is more than just "virtual memory"--it's a mechanism for juggling cached data and executable code based on frequency and recency of access. Also bear in mind that some operating systems more than others aggressively allocate physical RAM. By virtualizing swap with a RAM disk, one simultaneously enjoys the benefits of swap and the speed of RAM.

      Implementation of swap varies among operating systems, so at some point it's important to acknowledge the OS-specific issues involved when debating the swap vs. no-swap issue. Although many of the points raised in the discussion on kerneltrap.org are of general interest, some of them are Linux-centric. Suffice it to say that Windows manages swap comparitively poorly, and tends to page to disk more often than necessary. For that and other reasons, I would hypothesize that Windows machines have more room to benefit from volatile swap than Linux does.

    16. Re: If You have enough RAM by Black+Parrot · · Score: 1


      > You could make a big ramdisk and swap to that!

      I used to make that joke to VAX engineers when they came around to work on stuff, and they infallibly took the time to explain to me why it wasn't a good idea.

      --
      Sheesh, evil *and* a jerk. -- Jade
    17. Re:If You have enough RAM by martin-boundary · · Score: 5, Interesting
      I think this is the most interesting issue hinted on the mailing list.

      There are two "theorems" quoted: The first says that no matter what, if you have a size X of RAM used by the OS, and you add a size Y swap disk, you get better OS performance than if you only had X RAM.

      The second "theorem" says: if you have X RAM + Y swap disk, then add Y RAM and use that instead as the swap disk, then you get *faster* performance.

      The naysaysers now say that the second statement is misleading. Why? Because with X+Y RAM and Z swap disk, you'd get better performance again.

      I think this betrays an underlying assumption which I'm not sure is true, namely: X+Y RAM managed by the OS any way it likes is always better managed then X RAM managed by the OS any way it likes and Y RAM reserved for swap operations.

      In fact, let us suppose that the OS memory management is not optimal, ie when the OS manages X+Y amount of RAM, it does so suboptimally. Then it is possible that a different memory management scheme, e.g. X RAM used normally + Y RAM used exclusively for swap, may turn out to better use the available total RAM.

      So the theoretical question is this: is Linux's memory management sufficiently optimal that with an ordinary set of applications running, it can always make better use of X+Y amount of RAM than if it always reserved Y for swap? Alternatively, under what kind of running application mix is it true that reserving Y amount for swap yields a better memory management algorithm than using X+Y fully?

    18. Re:If You have enough RAM by Anonymous Coward · · Score: 0

      >> You could make a big ramdisk and swap to that!
      > I know one person that is quite good at tweaking MS Windows that actually claims this can be a good idea.

      I've seen some technical discussion of this on Windows boards, and it's not a good idea. Your disk will make less noise and some UI operations will be snappier, but the system will be slower.

    19. Re:If You have enough RAM by Anonymous Coward · · Score: 0

      That's not funny, because if you have say 768MB of ram, that's technically just 256MB for ram and 512MB for swap...

    20. Re:If You have enough RAM by Listen+Up · · Score: 2, Interesting

      They are not theorems, but conjectures. A theory and a conjecture are not the same thing. No one to date as posted a theory.

    21. Re:If You have enough RAM by Anonymous Coward · · Score: 0
      I can't believe I'm explaining this, but...

      It was a joke you see. whiteranger99x was suggesting that if you had 768MB of RAM, that you allocate a ramdisk 1.5GB in size to act as swap, which of course is impossible as you only have 768MB of RAM.

      Here ends the lesson of the day. BTW Any mods which label this post insightful gets a 4-by-2 on the back of their heads.

    22. Re:If You have enough RAM by wampus · · Score: 1

      Yeah, I did that once. I was bored. It crashed as soon as it hit the swap. Hard. Like power switch not working hard. I had to pull the plug.

      So I say, go for it! Remember to sync before you do anything memory intensive. :)

    23. Re:If You have enough RAM by whiteranger99x · · Score: 1

      Actually, if you read that properly, you'd see that I was playing a trick on the poster. I was saying if you have 1GB of RAM, and you set up a ramdisk for swap space to go ahead and make 2GB worth of hard drive space, poking fun at the old convention on how swap space is calculated.

      It isn't funny when people overthink jokes like that :(

      --
      Join the TWIT army now!
    24. Re:If You have enough RAM by kasperd · · Score: 1

      I don't have to compare them to tell you what result you should expect.

      256MB ram without swap is the fastest of the three you mention. 128MB ram and 128MB swap is the slowest. And 128MB ram and a 128MB ramdisk used as swap is somewhere between the two (probably closest to the 256MB of RAM). So taking a part of your RAM and using it as swap should slow down your system. If it actually increases performance, it doesn't indicate that it is a good idea, it just indicates you found a bug in the VM. If you can actually demonstrate a bug causing a decreased performance when using all your RAM as RAM, I'm sure there are people who would like to know about it.

      That is of course all assuming there is no difference in the speed of your RAM. If parts of your RAM have different speeds, it is an interely different story. It might improve performance to use the fastest parts of RAM as real RAM, and use the slowest parts of RAM as a ramdisk that you swap to. But it would be even better if the VM knew about the differences and could use the slow parts of RAM for more than just swap, but still keep the most used stuff in the fast parts of RAM.

      I have heard about cases, where a machine became slower by upgrading it from 64MB of RAM to 128MB of RAM, because the cache could only be used for the lower 64MB of RAM.

      --

      Do you care about the security of your wireless mouse?
    25. Re:If You have enough RAM by kasperd · · Score: 2, Insightful

      Alternatively, under what kind of running application mix is it true that reserving Y amount for swap yields a better memory management algorithm than using X+Y fully?

      I don't think you will find an application where that is the case. But maybe if the Y amount you allocate for swap happened to be slower than the rest of the RAM, it could improve performance. If all of your RAM has the same speed, the VM really have to be f***ed up to not give you better performance when it can manage all of your RAM.

      --

      Do you care about the security of your wireless mouse?
    26. Re:If You have enough RAM by martin-boundary · · Score: 1
      They are not theorems, but conjectures. A theory and a conjecture are not the same thing. No one to date as posted a theory.
      You'll note I put the word theorem in quotes, but that doesn't make them conjectures. Call them folk theorems if you don't think they can be fully demonstrated. The second claim is trivially provable so long as RAM is faster than disk, so that qualifies as a theorem no matter what, while the first claim was based on Nick Piggin's mail in the article, which strongly suggests to me he's got some theory to back up his claim, he says "The theory holds true no matter how much RAM you have. Swap can improve performance. It can be trivially demonstrated."

      Either way, perhaps there isn't a theory which could help settle the swap question I outlined, but I still think it's interesting.

    27. Re:If You have enough RAM by hobo2k · · Score: 3, Insightful
      I had to read that a couple times before I noticed the problem. You have the second theorem wrong. It should say: "X ram + Y swap is slower than (X + Y) ram with NO swap at all". Then, your question about managing X+Y ram wouldn't make sense because there is nothing to manage: either you run out of memory and apps die or you don't.

      Intelligent memory managment only affects performance if you have swap space. Swap space could be defined as storage which is slower than main memory. If all your storage is the same speed, memory management is trivial.

      Ironically, I have the same challenge for theorem #1 that you used for #2. #1 states that having swap is better than not having it. Clearly having swap increases the amount of allocations programs can make before their malloc's fail. But improve performance? That is only true if the OS can predict what data is needed for the future operations. If it predicts wrong, the usage of swap can degrade performance.

    28. Re:If You have enough RAM by martin-boundary · · Score: 1
      I don't think you will find an application where that is the case. But maybe if the Y amount you allocate for swap happened to be slower than the rest of the RAM, it could improve performance. If all of your RAM has the same speed, the VM really have to be f***ed up to not give you better performance when it can manage all of your RAM.
      I don't know, really. I'm not sure it's that clear cut. I imagine that if X fills up with lots of processes, you'd get fragmentation of memory. By having Y around and used agressively, you'd have, as a side effect, a simple automatic "defragmentation zone". Of course, I don't know, just guessing. But maybe someone on /. can comment.
    29. Re:If You have enough RAM by Danny+Rathjens · · Score: 1
      That is precisely what you do when you have two different speed DIMMs or ISA RAM.

      Back in the days when RAM was expensive, I had something like a 16MB DIMM with 70 ns access time, and a shiny new 32MB DIMM with 10 ns access time. I was thinking I would be 31337 if I hacked the kernel to let me form a ram disk from the slower RAM specifically and then I'd just make the slow ramdisk a higher priority swap than the disk swap partition.

      I was excited since I found something that looked like it hadn't been done yet and seemed somewhat useful and doable. However, after a bit of experimenting and researching how to make the necessary changes I discovered that, indeed, a patch was already available to do it. ;)

    30. Re:If You have enough RAM by jmalicki · · Score: 1
      I don't know, really. I'm not sure it's that clear cut. I imagine that if X fills up with lots of processes, you'd get fragmentation of memory. By having Y around and used agressively, you'd have, as a side effect, a simple automatic "defragmentation zone". Of course, I don't know, just guessing. But maybe someone on /. can comment.
      I see no reason to believe that memory fragmentation is a bad thing. Unlike filesystems, where you have chains of extents, essentially a linked list, which has linear performance for data access based on the number of extents, memory lookup is based on a multi-tiered set of arrays, called page tables, and access time is always constant (with respect to fragmentation at least), no matter how badly fragmented it is.
    31. Re:If You have enough RAM by martin-boundary · · Score: 1
      I had to read that a couple times before I noticed the problem. You have the second theorem wrong. It should say: "X ram + Y swap is slower than (X + Y) ram with NO swap at all". Then, your question about managing X+Y ram wouldn't make sense because there is nothing to manage: either you run out of memory and apps die or you don't.
      You're right, I thought that's what I said, but it's good to be clear. I'm not convinced there is no management issue with X+Y ram however.

      If you run lots of programs, doesn't your ram start fragmenting at some point? At the lowest level, you can maybe move regions of memory around, or map them through an extra layer of indirection (ie build a complicated chain of linked pages). So you could see my question as asking "does reserving a region Y as mostly empty help make the management of X more efficient?" Maybe it doesn't, but I'm not sure.

      Think of a drawer full of small objects. If there's some room to move objects about, it's easier to find/extract things than if the drawer is completely full.

    32. Re:If You have enough RAM by sploxx · · Score: 1

      IANAKH (kernel hacker), but IMHO this *can* make a difference. Because the application which queries for available memory gets only the value "free RAM+cached disk blocks" back.

      So with this approach, you can constrain the hunger of applications for RAM because they will notice that there is not too much. The RAM you allocated for the RAM disk swap partition does not count!

      Of course, there would be better ways to get this behaviour ;)

    33. Re:If You have enough RAM by kasperd · · Score: 2, Interesting

      True fragmentation of memory does not mean performance decrease. But fragmentation can still be a problem in some cases. For example if you need to allocate multiple pages at once, and only have scateret single pages available, the allocation would either fail, or you would have to free some memory. This is one of the reasons the task struct + stack allocation in Linux have finally been reduced from two to just one page (on x86 that is, I don't know about other architectures).

      Another possibility, that has been suggested for 2.7 is defragmentation of memory. Of course just because it has been suggested doesn't mean it is going to happen. Without defragmentation, what are your options to satisfy a larger allocation in case of fragmented memory? You'd have to free some memory, either by reducing the disk cache size, swapping out anonymous pages, or find some slabs that can be freed. But notice that with more memory there would be more possible choices for what to free, so it would have a better chance of picking something you won't need in the near future. If you used some ram for a ramdisk for swap, then you should not expect to use all of that ram. So effectively you are using less of your memory, which again could mean smaller chance of finding what you need in RAM. The failing allocation might as well be satisfied by removing a page from the page cache, which is certainly less disirable.

      Of the given suggestions defragmentation of memory is probably the only that shouldn't cause performance problems in specific corner cases. (Me thinking back on the good ol' days with MS DOS and AmigaOS where the only solution to memory fragmentation was a reboot).

      --

      Do you care about the security of your wireless mouse?
    34. Re:If You have enough RAM by Anonymous Coward · · Score: 0

      I've seen some technical discussion of this on Windows boards, and it's not a good idea. Your disk will make less noise and some UI operations will be snappier, but the system will be slower.

      Ummm... so surely it IS a good idea if you care more about a quieter working environment and about snappy UI?

    35. Re:If You have enough RAM by tomstdenis · · Score: 0, Redundant

      But that's a horrible waste of 256M of ram. I dunno what y'all are whining about but I never really noticed swap problems on either of my own boxes [512M ram in desktop, 768M in laptop].

      Just set aside a few hundred M for swap and be done with. Specially since HD space is so cheap.

      Tom

      --
      Someday, I'll have a real sig.
    36. Re:If You have enough RAM by Anonymous Coward · · Score: 0
      I think this betrays an underlying assumption which I'm not sure is true, namely: X+Y RAM managed by the OS any way it likes is always better managed then X RAM managed by the OS any way it likes and Y RAM reserved for swap operations.

      Not exactly. It says that:

      X+Y RAM + 0 RAM dedicated for swap + Z disk swap

      is better than

      X RAM + Y RAM dedicated for swap + 0 disk swap.

    37. Re:If You have enough RAM by sydb · · Score: 1

      I have heard about cases, where a machine became slower by upgrading it from 64MB of RAM to 128MB of RAM, because the cache could only be used for the lower 64MB of RAM.

      I have heard this too, but I don't really understand it.

      If the system with 64Mb needed more memory, then it was using swap.

      Swap is obviously slower than memory, even without cache.

      So although increasing the memory above the cacheable threshold would not reap the benefits of cache above that threshold, it would reap the benefits of not using swap.

      You would see performance degrade if the operating system has a preference for memory above the cacheable threshold, but why would this be so?

      File cache could grow to use the extra memory and force applications into the uncacheable area, but then you would reap the benefits of more file cache, i.e. less disk access.

      Either way, it seems an odd claim.

      --
      Yours Sincerely, Michael.
    38. Re:If You have enough RAM by Anonymous Coward · · Score: 0

      "...the VM really have to be f***ed up...."

      Par for the course for Linux. Rememeber the Great VM Replacement in 2.4.10? Or the current mess with reverse mapping?

    39. Re:If You have enough RAM by CmdrTHAC0 · · Score: 1

      I think you're confusing virtual and physical memory. Even in the case of highly fragmented RAM, an application can be given a "continuous" chunk of memory from its perspective even though the physical pages backing them are scattered around in RAM. That's why the page tables (and TLB) exist.

      --
      __CmdrTHAC0__
      In Soviet Russia, Spanish Inquisition doesn't expect YOU!!
    40. Re:If You have enough RAM by lightcycle · · Score: 1

      How about making a ramdisk to use for swap, and then compress it with doublespace/drivespace or whatever it's called. Then you'd increase the amount of space, and in RAM you probably won't notice any slowdowns from compression.

      --

      The stars that shine and the stars that shrink
      in the face of stagnation the water runs before your eyes
    41. Re:If You have enough RAM by Anonymous Coward · · Score: 0

      The use case for 'ram drive swap' proponents was the 30 seconds their system thrashes after quitting a large game. Seems like a silly thing to try to optimize (because it might make their game slower).

    42. Re:If You have enough RAM by Anonymous Coward · · Score: 0

      Feh, 1) good attiude, "let's argue semantics instead of addressing the content." 2) Yes, a theorem can be a conjecture. Yes, theorems were posted, "Suppose that ...; then doesn't it mean that ...?"

    43. Re:If You have enough RAM by ceswiedler · · Score: 3, Interesting

      Adding RAM always helps. No one ever says that swap is BETTER than RAM. Having X+Y RAM is better than X RAM + Y swap. However, having X+Y RAM plus Z swap is better yet.

      Sure, add more RAM. But swap will always be useful, because there's always some stuff which is better off on the disk, because it hasn't been used in forever, and until your RAM is larger than your HD, you'll get better milage out of that RAM if you use it as a cache.

    44. Re:If You have enough RAM by kasperd · · Score: 1

      I think you're confusing virtual and physical memory.

      No I'm not. You are confusing kernel space and user space. Kernel space allocations have to be contiguous in both physical and virtual address space.

      --

      Do you care about the security of your wireless mouse?
    45. Re:If You have enough RAM by kasperd · · Score: 1

      Rememeber the Great VM Replacement in 2.4.10?
      I remember hearing about it, but I don't think I ever noticed a difference.

      Or the current mess with reverse mapping?
      AFAIK the performance is fine, the worst problem is the amount of memory it consumes for management. But Andrea Arcangeli has a solution.

      --

      Do you care about the security of your wireless mouse?
    46. Re:If You have enough RAM by kasperd · · Score: 1

      Not using cache for the uppermost 64MB on a 128MB system essentially means the uppermost 64MB will be slower. So does the allocation work bottom up or top down? I actually don't know. But that only matters in the begining. When the system has been running for a long time memory is so fragmented that you are essentially using random parts of your memory.

      When you boot a 64MB system and finally have X running, some pages will probably already be swapped out. But many of those you are probably never going to need. So while it did slow down the boot a bit, the performance of the system is fine. If you add 64MB of memory to this system, and those 64MB are slower, what could happen is, that no pages are swapped out. So those pages you don't need are now in your fast memory instead of on the swap partition. The pages you really need get some slow pages instead.

      So the kernel thinks nothing is wrong, because it doesn't know some of the RAM is slow. But in reallity half of your memory accesses will have to go to RAM insted of cache. So whenever you should have had two cache hits, you now get one expensive RAM access. So assuming the RAM is ten times as slow as the cache (not unrealistic), the slowdown would be a factor of five.

      I never had one of those computers myself, so I don't have any meassurements to backup the theory. Luckily my computers always got faster when I added more RAM.

      --

      Do you care about the security of your wireless mouse?
    47. Re:If You have enough RAM by grmoc · · Score: 3, Insightful

      When you're DMAing large amounts of memory, memory fragmentation becomes an issue.

      This is why the 'bigPhysArea' patch to the kernel exists-- to create continuous bloakcs of memory which can be transferred without having to scatter/gather.

      Note that this is independant of memory -usage-.. this is an issue with the 'block size' if you will, of memory segmentation.

    48. Re:If You have enough RAM by sydb · · Score: 1

      If you add 64MB of memory to this system, and those 64MB are slower, what could happen is, that no pages are swapped out.

      This is the bit I was unsure about; I thought that pages which had not been used for a while would be swapped out even if memory was plentiful. I remembered I have a copy of "Understanding the Linux Kernel" and it confirms that pages are only swapped out in low-memory circumstances.

      I'll give it some more reading! Thanks for your input!

      --
      Yours Sincerely, Michael.
    49. Re:If You have enough RAM by Anonymous Coward · · Score: 0

      Hahahaha, when you explain the joke it makes it so goddamn funnay! Thanks!

    50. Re:If You have enough RAM by Trepalium · · Score: 1
      The problem was the level 2 and/or CPU caches couldn't cache over 64MB on those boards (mostly pentium and earlier). Instead of hitting the faster cache memory, you were hitting the much slower main memory. If you want to see the difference in performance of this on one of those older machines, all you need to do is turn off the caches in the system's BIOS. A system that would boot Windows 95 in a couple minutes would turn into one that took up to 10 minutes to boot.

      Now, the problem with all of this is that the OS is generally unaware of the fact this memory over 64MB is dog slow. Most OS's prefer using physical RAM over swap because it's a well known fact that access disks is slower than accessing RAM. If the OS had been aware of this slow RAM, it could've used that additional RAM just as it would've used swap, or EMS memory (remember that?). Nearly all, however, blindly assumed that all memory was created equal in the system.

      --
      I used up all my sick days, so I'm calling in dead.
    51. Re:If You have enough RAM by hobo2k · · Score: 1
      does reserving a region Y as mostly empty help make the management of X more efficient?
      Okay, I think I understand now. IMHO, I don't think that is necessary.
      [maybe you can] map [regions of memory] through an extra layer of indirection.
      This is exactly what modern VM systems do. Every application has a private virtual address space so it can allocate memory at almost any virtual address. The VM manager maps addresses from the virtual space to real memory (or swap file). IIRC, the CPU supports translation look-aside buffers (TLB) which make this very fast. So an application can get a big linear block of virtual memory even if the actual memory must get scattered. In theory ram has no 'seek time', so this scattering doesn't matter.

      Things are further simplified with memory pages. The VM manager handles memory in constant sized blocks, so finding free memory is quick. Your language's runtime implements application-private mem management on top of those blocks. But that is all in virtual addresses, needing no knowledge of swap or physical ram.

      Well, anyway, that's my dusty understanding of VM design anyway. ;-)

    52. Re:If You have enough RAM by tlhIngan · · Score: 1

      Speaking of which, wasn't there a time when the PowerPC chip first came out, that MacOS actually ran *FASTER* with swap on (up to a very complicated formula)? So if you had X RAM, and zero swap, your system would perform OK, but if you added Y swap (where Y = magic_formula(x)), your powermac would improve performance 10% or so?

      Heck, even that went against conventional wisdom of the day (don't use swap at all), but it was supposed to make a difference. Still can't remember why, other than perhaps MacOS' awful memory manager...

    53. Re:If You have enough RAM by gerardrj · · Score: 1

      No, it wasn't an issue of speed, it was that with VM turned on a native PPC application needed less RAM to operate than if VM was turned on.
      Turning on VM still slowed things down a bit, especially during swapping.

      --
      Article X: The powers not delegated... by the Constitution...are reserved...to the people
    54. Re:If You have enough RAM by kasperd · · Score: 1

      This is the bit I was unsure about; I thought that pages which had not been used for a while would be swapped out even if memory was plentiful.

      Actually that doesn't make any difference. In some cases it would make sense to write pages to swap when they haven't been written to for a while, even if you have loads of free memory. But it only makes sense as long as you support having a copy of the page both on swap and in RAM. The point would be, that if you have a copy in each place, you can quickly discard one of the two, if you would ever need to. But removing the copy from RAM as long as you have free RAM would be stupid. And writing pages to swap if the disk is busy doing other work wouldn't be a good idea either (unless of course you are already out of RAM).

      So whether there is a copy of the pages on swap or not, they will still take up a page of your fastest RAM. There is no need to remove them from RAM yet, because there is plenty of slow RAM free. (Remember the kernel doesn't know it is running on a broken computer where some of the RAM is slow). But I don't think Linux starts writing pages to swap before it needs to.

      --

      Do you care about the security of your wireless mouse?
    55. Re:If You have enough RAM by Anonymous Coward · · Score: 0
      Interesting data point: apparently, the way the memory manager in Windows 3.x is designed, the system will work better if you have a swap file, regardless of the amount of RAM you have. That means that, with a very large quantity of RAM, you should create a RAM disk out of some of that RAM, and stick the swap file on that RAM disk. The resulting performance is better than if you just left the RAM alone.

      Ok, nobody in their right mind will be running 3.x on modern hardware... but it's an interesting datapoint nonetheless.

    56. Re:If You have enough RAM by julesh · · Score: 1

      It could actually work, if you have a compressed ramdisk implementation.

    57. Re:If You have enough RAM by tricorn · · Score: 1

      Turning on VM allows the program to start up faster, as it uses demand paging from the executable file. Without it, the entire executable must be loaded into memory. That's why it takes more memory as well. You can enable VM with as little as 1MB more than actual RAM. This only applies up to MacOS9, MacOSX uses more conventional swapping.

      Programs like RAMDoubler enabled you to turn on VM, but without turning on swap. The main function of RD was, however, to compress memory instead of swapping it out. For a fast processor and a slow disk, that can be faster than swapping.

    58. Re:If You have enough RAM by julesh · · Score: 1

      Games are a case where, usually, there is a 'fast enough' point, beyond which nobody really cares; that is, all the graphics run smoothly enough that you don't see flicker, there aren't noticeable stutters or other delays, and the game isn't scaling anything back (e.g. detail levels, or a.i. capability) in order to compensate.

      If you've got fast enough, then maybe optimising the swap-back-in stage afterwards is the best thing to do.

  4. they need updated docs for todays ram amounts by Anonymous Coward · · Score: 5, Insightful

    All the docs on Linux and swap amounts to use are from the days of 386s and 4 megs of ram!

    I want to know how much swap I should REALLY be using for a system with 1 gig of ram.

    Same for some of the kernel compilation docs. Maybe on a 4 meg system compiling that extra option might cause slowness but on a 500 meg system does an extra 30k in the kernel matter?

    Can we get some docs that aren't from the mid 90s!

    1. Re:they need updated docs for todays ram amounts by rd4tech · · Score: 2, Insightful

      Start running bunch of applications and seeing what happens with the memory and the swap. The swap hardly gets used at all if you have 1GB RAM. On the other hand, on my old 486 with 32MB of RAM, swap was the main thing.. Sometimes several hundred MBs

    2. Re:they need updated docs for todays ram amounts by zoloto · · Score: 1

      Better safe than sorry. An old tried and true motto that has always worked for me.

      RAM x2 = SWAP

      Even still today with my laptop with 1 gig of ram, I run a 2 gb swap file in linux even if 1/4 of it isn't even used.

    3. Re:they need updated docs for todays ram amounts by superjaded · · Score: 0

      I have 512Mb of ram in both of my systems (Linux running a Duron, and Used-to-be-running Windows (in the middle of installing gentoo on it now ;)) on a Athlon XP), Windows is the only system that has complained that my virtual memory is too low.

      And believe me, I tax my Linux box WAAAY more than I tax my Windows machine. It works both as a small server as well as my primary desktop.

      Oh yeah, and while I had the defaults on for virtual memory/swap for Windows, I have no swap file/partition in Linux.

    4. Re:they need updated docs for todays ram amounts by Eskarel · · Score: 2, Insightful
      Well that's really not a totally fair comparison. True, you may use far more resource intensive apps on your linux machine, but unless you're running some varation of wine(and even to a certain extent then) it's not likely many of those apps are games.

      A heavily used server is really not comparable to a game even if it seems like it uses more resources simply because it's far more likely to be well written than your average game. I've seen some seriously nasty memory leaks in popular games that I'd never see in something which was better designed be it for Windows or Linux.

      If you were comparing running the same app on windows vs linux then perhaps you could criticize the memory manager(which is honestly probably not as good), but you're not.

    5. Re:they need updated docs for todays ram amounts by dustmite · · Score: 1

      Windows' (2K/XP) virtual memory management is retarded. If you have 512MB RAM, it will start eagerly dumping as much as possible onto the HD when your memory usage reaches 256MB, LONG before you really need to start swopping, trying hard to keep that upper 256MB of real memory free. So performance in Windows degrades much faster than it really needs to. We were developing terrain visualisation systems that required a certain, known amount of RAM, about 400MB, so we bought 512MB systems, which is more than enough to hold both our application and the OS without ever so much as touching the swap file. But Windows started swapping and slowing down very noticably as one moved around the terrain database. We did a little system monitoring and noticed that it would always start swapping things out at 256MB. I'm not sure what this point is if you have 1GB RAM.

    6. Re:they need updated docs for todays ram amounts by Donny+Smith · · Score: 1

      >We were developing terrain visualisation systems that required a certain, known amount of RAM, about 400MB, so we bought 512MB systems, which is more than enough to hold both our application and the OS without ever so much as touching the swap file.

      Congratulation - you can safely disable your swap file!

    7. Re:they need updated docs for todays ram amounts by dustmite · · Score: 1

      Indeed .. but I think Windows complains if you turn off swap. I can't remember what we actually did about it in the end though. Note this was back when 512MB was considered a LOT of RAM. I remember doing some research about this, and found some sites on the Web that said that making the swap file larger would help too. Something about causing it to set that "threshold point" higher.

    8. Re:they need updated docs for todays ram amounts by Dahan · · Score: 1
      That's a feature/design decision. Windows NT writes pages that haven't been accessed recently to swap while the system is idle, so that when the system is low on RAM, it doesn't have to spend time paging stuff out. The pages are already in the swapfile and it can reuse that RAM immediately.

      Seems to work fine for me--I don't notice any slowdowns until my working set size exceeds RAM size. I dunno; if your app uses about 400MB, leaving 112MB for Win2K to use seems a bit tight to me.

    9. Re:they need updated docs for todays ram amounts by jawtheshark · · Score: 1
      Stupid question: if I have 4Gigs of RAM, what kind of swap space do I need? 8Gigs? I forgot everything about my classes about virtual memory, but isn't it a fact that 32-bit machines can only access 4Gigs of RAM? So what's the point of a swap once you hit that limit?

      I indeed knew about the 2xRAM=SWAP, and have used it since my 486 days (before that my system was a 286, so no swap there). My situation is the same as yours: 1Gig RAM, 2 Gigs swap. It rarely gets used though.

      --
      Ahhh...the great dumpster continuum. Many a free computer will be found there. -- sowth (748135)
    10. Re:they need updated docs for todays ram amounts by 42forty-two42 · · Score: 1

      Only 4Gb can be mapped at any given time. WIth various extensions, up to 16Gb physical RAM can be used (with a performance hit), and swap is limited only by the OS. However, no single user-level program can use more than 4Gb of it at any one time (barring IPC shared memory or other tricks)

    11. Re:they need updated docs for todays ram amounts by n0d3 · · Score: 1

      Mem: 516264k total, 394528k used, 121736k free, 126580k buffers Swap: 136544k total, 0k used, 136544k free, 87092k cached this is my workstation ... XP 2400+ Unfortunatly I just rebooted yesterday while upgradeing my ATi drivers (i borked my xorg.conf : / and had to reboot to be able to 'see' anything again) Mem: 1033520k av, 1020680k used, 12840k free, 0k shrd, 151760k buff 411928k active, 500508k inactive Swap: 627472k av, 2612k used, 624860k free 546496k cached Here's our 1.4Ghz 1Gbyte RAM server. It also doesn't have a big uptime (16 days or so cos to power failure : /) however it runs heavly used http daemon, which relies on postgres daemon and runs 2 Enemy Territory servers (inactive right now). When setting up I did decide against the ram x2 rule but watned to make sure i'd never run out of ram with all servers running (it's a heavly used machine) So i created 650mb swap partition. However I could have done with so much less. Swap was really needed back in the days, But I guess now adays you really don't need more then 128 - 256 mb. Having swap around remains to be handy, and if you notice a lot of swaps and a lot of runnig out of mem, then i guess you're better off increasing ram then swap. I guess the 'modern' calculation of swap should be something along the lines, per 512mb ram, increase swap by something around 128mb ...or so. just my E0.02

    12. Re:they need updated docs for todays ram amounts by n0d3 · · Score: 1

      Mem: 516264k total, 394528k used, 121736k free, 126580k buffers
      Swap: 136544k total, 0k used, 136544k free, 87092k cached

      this is my workstation ... XP 2400+ Unfortunatly I just rebooted yesterday while upgradeing my ATi drivers (i borked my xorg.conf : / and had to reboot to be able to 'see' anything again)

      Mem: 1033520k av, 1020680k used, 12840k free, 0k shrd, 151760k buff
      411928k active, 500508k inactive
      Swap: 627472k av, 2612k used, 624860k free 546496k cached

      Here's our 1.4Ghz 1Gbyte RAM server. It also doesn't have a big uptime (16 days or so cos to power failure : /) however it runs heavly used http daemon, which relies on postgres daemon and runs 2 Enemy Territory servers (inactive right now). When setting up I did decide against the ram x2 rule but watned to make sure i'd never run out of ram with all servers running (it's a heavly used machine) So i created 650mb swap partition. However I could have done with so much less. Swap was really needed back in the days, But I guess now adays you really don't need more then 128 - 256 mb. Having swap around remains to be handy, and if you notice a lot of swaps and a lot of runnig out of mem, then i guess you're better off increasing ram then swap.
      I guess the 'modern' calculation of swap should be something along the lines, per 512mb ram, increase swap by something around 128mb ...or so.

      just my E0.02

      God damnit HTML mode .... sorry for the double post, but since /. still doesn't feature an edit button ... : )

    13. Re:they need updated docs for todays ram amounts by vadim_t · · Score: 1

      Sorry, that's completely stupid.

      I used to run a mail server with 128MB RAM and 256MB swap, just like you suggest. It mostly ran fine. However, then I set up spamassassin and procmail to download mail from my ISPs account.

      Since the CPU and network were slow, spamassassin couldn't finish before a new mail was delivered, so the queue grew. Soon this consumed so much RAM that it started using swap, slowing things down even more, and making the queue grow even faster... this situation would get out of hand in less than 10 minutes.

      The end result would be a computer swapping like mad, with a load average of 70, and completely unusable for at least 3 or 4 hours.

    14. Re:they need updated docs for todays ram amounts by Pantheraleo2k3 · · Score: 1

      Add this to your Win.ini file under [386enh] to fix that:

      ConservativeSwapfileUsage=1

      I haven't noticed much difference, but try it and see if it helps you

    15. Re:they need updated docs for todays ram amounts by Pantheraleo2k3 · · Score: 1

      I just tried to do that on my newly reinstalled Windows XP box and realized it was system.ini, not win.ini Hope no one b0rked any boxen with that

    16. Re:they need updated docs for todays ram amounts by Anonymous Coward · · Score: 0

      It seemed that the "/proc/sys/swappiness" equivilent on NT4 was pretty agressive. I think this was legacy the pressure to get the mimimum specs (12MB!) competitive with OS/2.

      I haven't noticed thrashy behavior with XP -- although when the system is idle the autodefragger will grind the disk quite a bit.

    17. Re:they need updated docs for todays ram amounts by ceswiedler · · Score: 1

      Clearly you don't understand that there are more uses for your RAM than the working set of your applications. Please go study the subject before complaining. Specifically, pay attention to the fact that Windows is using that RAM as a cache, and as a result your disk accesses are orders of magnitude faster.

      This is turning into the new 'X is slow because it runs over a socket interface' idea. People, your computer isn't stupid, it's using that RAM for good purposes, please either trust it or study the subject so you can discuss it sensibly.

    18. Re:they need updated docs for todays ram amounts by Anonymous Coward · · Score: 0

      RAM isn't that expensive. Go mow a yard for somebody and you can easily add at least another 128mb of ram to that machine.

      I wouldn't build ANY server with less than 512, period.

    19. Re:they need updated docs for todays ram amounts by DunbarTheInept · · Score: 1


      since /. still doesn't feature an edit button ...
      ...people can't make revisionist modifications to things they said earlier in a debate. This is a good thing. Editing would only be good if it was disabled once someone says something that refers to your post. Checking for the use of the "reply" link doesn't work for this, because that still doesn't catch the case where someone replies obliquely to what you said in a post that was not a direct reply.

      Basically, you can't unsay things in an in-person conversation, why do you want it in an on-line conversation? Yeah, I know in this case you just wanted to fix up some formatting, but slashcode doesn't know that, and can't know that.

      If you're doing something where the formatting matters, then use the preview button.

      --

      Don't label something "offtopic" unless you know the topic well enough to tell what's on topic.

    20. Re:they need updated docs for todays ram amounts by ptlis · · Score: 1

      ConservativeSwapfileUsage=1 only works on WinME boxes and earlier, it does not apply to Win2k/WinXP...

      --
      There's mischief and malarkies but no queers or yids or darkies within this bastard's carnival, this vicious cabaret.
    21. Re:they need updated docs for todays ram amounts by n0d3 · · Score: 1

      i'm aware of this, however i'm used to 'plain old text' with UBB code sometimes. They 'convert' the \cr to
      's : )

      Don't do much posting on /. really .. but i'll see if there's an preference setting somewhere to have it automagically post in txt

  5. Where many people miss the point... by NerveGas · · Score: 4, Insightful


    People like to claim that swap can always improve performance, by swapping out unused sections of memory, allowing for more memory to throw at apps or disk cache.

    Well, *most* apps won't just arbitrarily consume memory, so endless amounts of memory won't help. And disk cache gets you greatly diminishing returns.

    One of the machines I use has 3 gigs of memory. It will swap out unused programs, in an attempt to free up more memory. The joke is that it simply can't use all three gigs. After half a year of uptime, there's still over half a gig completely unused, because the apps don't take memory, and there's not that much to put in disk cache.

    Obviously, that's a pathological case. And there are pathological cases at the other extreme. But as memory prices keep dropping over the long run, swap does become less and less useful.

    steve

    --
    Oh, you're not stuck, you're just unable to let go of the onion rings.
    1. Re:Where many people miss the point... by Anonymous Coward · · Score: 0

      Actually Linux will use every MB for diskcache and will continue keeping it in memory aslong as the cache is consistent or it has to cache new things
      (very funny with having complete CD images in memory and such)

    2. Re:Where many people miss the point... by Anonymous Coward · · Score: 2, Informative

      One of the machines I use has 3 gigs of memory. It will swap out unused programs, in an attempt to free up more memory. The joke is that it simply can't use all three gigs. After half a year of uptime, there's still over half a gig completely unused, because the apps don't take memory, and there's not that much to put in disk cache.

      Yes, it is swappnig because it is trying to free up "low memory", of which you have less that a gig. This is unfortunately an inevitable failure case of Intel's brain damaged (although practical) PAE schmeme.

      Were you to have no swap at all, you may have had to reclaim important kernel side caches (inode, dentry caches), or even had memory alloction failures in eg. the network stack (common).

    3. Re:Where many people miss the point... by anthony_philipp · · Score: 1

      but one nice thing about swap is that when your system fails everything in RAM can be dumped into swap, this may help give you and idea about what caused the problem in the first place. however in your case keeping 3 gigs of swap around just in case your system fails probably isnt worth it. then again if you have 3 gigs of RAM you can afford a larger hard drive and put some swap on it.

    4. Re:Where many people miss the point... by Anonymous Coward · · Score: 0

      schmeme

      Err, scheme. OTOH, schmeme sounds pretty funny and is possibly an accurate description of IA32's PAE.

    5. Re:Where many people miss the point... by zx75 · · Score: 1

      Ok, well you might not have a use for an OS that swaps, but most of the rest of us don't have three gigs of memory on our systems and run them for months at a time.
      Myself? I code for fun and profit, and I know that there are times that I need to push my computer hard, and I do have a gig worth of memory, but even so I've run out of swap space of my system partiton a time or two despite having another gig and a half allocated for that purpose.

      --
      This is not a sig.
    6. Re:Where many people miss the point... by arekq · · Score: 1

      Sometimes when I need to use some big files, especially over the network, I "cat file >/dev/null" first and watch it fill the memory. :)

    7. Re:Where many people miss the point... by ErichTheWebGuy · · Score: 1, Funny

      Well, *most* apps won't just arbitrarily consume memory

      I assume you are excluding Windows Explorer, Internet Explorer, Windows 98, Windows ME, Word, Excel, etc.

      --
      bash: rtfm: command not found
    8. Re:Where many people miss the point... by arekq · · Score: 1

      Can I have 3 gigs of RAM and still be stingy? :-)

    9. Re:Where many people miss the point... by torinth · · Score: 3, Insightful

      What about the basic situation of not setting a hard-to-describe limit on desktop users? Managing and disabling swap is great in controlled environments like servers and embedded systems, where the applications being run are limited and pre-determined.

      But on desktop systems, a user may want to use Word, Photoshop, Outlook, Internet Explorer, an anti-virus tool, 30 other system tray tasks and services, etc. Should this user sit there and add up the recommended RAM of each of every application she owns and use that as a guideline for buying? That seems a little over-complicated and wasteful. Most of the time, she won't be running every application, but she really should be able to when she wants to.

      The solution is to introduce a cheap storage tool to extend what's treated (by applications) as RAM--swap.

    10. Re: Where many people miss the point... by Black+Parrot · · Score: 1


      > however in your case keeping 3 gigs of swap around just in case your system fails probably isnt worth it

      It has been a while since I've priced disk drives, but last time I checked it only cost about $10 to go up to the +20GB larger size, so that 3GB swap file should cost him about $1.50.

      --
      Sheesh, evil *and* a jerk. -- Jade
    11. Re:Where many people miss the point... by Anonymous Coward · · Score: 0

      You may need to find a better memory monitoring tool. If you have over 3 gig of storage and accessed it at least once in the last half year, you have used that full 3 gig. I'm quite certain that there is no modern OS which will not take full advantage of availible memory by caching hard drive reads. Most likely the tool you are using to monitor memory usage isn't tracking that.

    12. Re:Where many people miss the point... by Anonymous Coward · · Score: 0

      You might want to read
      http://kerneltrap.org/node/view/3000
      to find out how to fine tune swap-behavior.
      (check out /proc/sys/vm/swappiness)

    13. Re:Where many people miss the point... by kasperd · · Score: 2, Interesting

      Yes, it is swappnig because it is trying to free up "low memory", of which you have less that a gig.

      Actually this sounds likely, but is it a good idea? Alternatively it could do a memcpy of your data from low memory to high memory. So now you have the choice between occupying the CPU to perform the memcpy, or occupying the disk controller to swap it out. But data that you could swap out is process memory, which you'd expect to be allocated from the high memory. So how do you actually reach a situation where process memory pages end up in low memory? You'd have to fill up the high memory first. Of course if you run a program that requires a lot of memory, which is all allocated from high memory, then other programs might get low memory. When the first program terminates you could have a lot of free high memory and other programs still taking up the low memory.

      --

      Do you care about the security of your wireless mouse?
    14. Re:Where many people miss the point... by Alioth · · Score: 4, Interesting

      The 2.6 kernel now has a swappiness setting in /proc where you can tell the kernel avoid swapping please (set it to zero) or swap like mad (set it to 100). Therefore you can tune your system to your specific needs. It'd be nice if they had a similar control for filesystem cache.

    15. Re:Where many people miss the point... by joib · · Score: 4, Informative


      It'd be nice if they had a similar control for filesystem cache.


      You're missing the point. That's exactly what the swappiness setting does, indirectly. If you avoid swapping (swappines = 0), the system has less memory left over for filesystem cache. OTOH, if you set swappiness=100, the system has a lot more memory to use for file cache.

      The system always tries to use all available memory, and that's a good thing. The question is whether to use extra memory for file cache or for keeping pages in memory.

    16. Re:Where many people miss the point... by mindstrm · · Score: 1

      The average user can do all that just fine in 512MB of physical ram, in windows, with swap disabled completely. 512MB is so cheap, it's irreelvant.

      That's the point here... swap is not nearly as important as it used to be.

    17. Re:Where many people miss the point... by torinth · · Score: 1

      The average user can do all that just fine in 512MB of physical ram, in windows, with swap disabled completely. 512MB is so cheap, it's irreelvant.

      That's totally inaccurate. Have you ever worked with Photoshop? It's not just for graphic designers anymore. Working with just one or two layered images from some 5 megapixel CoolPix or something can eat up that memory like crazy.

      What you just said is remarkably similar to the philosophy behind the "640k is plenty!" philosophy. Swap freed us from such presumptive declarations.

      Can we improve how swap is used? Yes. Should we encourage people to disable swap on desktop systems? You'll be hard pressed to find a reason.

      If nothing else, you can have a VMM ignore swap unless or untill actual RAM is (say) 80% full. You get "no swap" performance but still have the option of buffering your RAM in an emergency.

    18. Re:Where many people miss the point... by mindstrm · · Score: 1

      No, it's not "640k is plenty"

      I'm saying this because I DO it, on a daily basis.

      Photoshop has it's own swapfile mechanism.

      I didn't say "it's enough for everyone".
      I know a number of people that run without swap, and all have no problems.

    19. Re:Where many people miss the point... by torinth · · Score: 1

      Fine. Let me rephrase that:

      Everywhere I put Photoshop put "Crappy 3rd-party off-the-self product that acts like Photoshop but was built by 2nd rate developers who don't manage resources well, but which is 1/10th the cost of Photoshop."

      Said application certainly does not an efficient swapfile mechanism of it's own, and therefore needs a lot of what it thinks is RAM.

      If you choose to live without swap, more power to you, but it's a damn good safeguard for ignorant people who use software by ignorant developers.

    20. Re:Where many people miss the point... by DunbarTheInept · · Score: 1

      How is it that a system with 256 M of Ram plus 256 M of swap is better than one with 512 M of Ram? This is what your argument favors, even if you don't realize it. No matter what level you set your swap to, it will always be a finite size. But the only way to solve the kinds of problems you talk of is to have infinite ram, and swap doesn't do that for you.

      This is getting back to the original question in the article - if my system performed okay with X amount of Ram and X amount of swap, then it should perform just great with 2X amount of ram and no swap, assuming the usage of the machine is the same. Why use swap then if I can afford to double the RAM? I thought swap was just for the case where my usage can't fit in my RAM. And clearly it has already been proven that it fits in 2X megabytes if I was previously running with X ram plus X swap.

      And the answers in the article astonished me. They seemed to be paraphrasing "the way the kernel uses ram is stupider than the way it uses swap, and therefore having some swap improves performance." If that's the case then something is really wrong with the design.

      --

      Don't label something "offtopic" unless you know the topic well enough to tell what's on topic.

    21. Re:Where many people miss the point... by mindstrm · · Score: 1

      Look.

      My old system had 256MB of ram, and 256MB of swap.

      My NEW system has 512MB of ram.

      I do the same tasks.

      Now tell me, if I could do EVERYTHING I needed to do on the old system, why is it I *NEED* swap on the new system?

      Yes.. different swapping mechanisms can make this an almost moot point... with linux, I'd say, actually, yes, USE swap, because it doens't swap like a punk prematurely.

      With windows, I find it works better without it. I'm sure it could also just be tuned.

      This is getting away from the point though.
      The point is:
      Real physical memory is preferable to swap. If the total virtual ram you want is 1 gig, it's better to have 1 gig of ram than half a gig of ram and half a gig of swap. That's the ONLY point.

      With ram prices being what they are these days, it's quite easy to run a system without swap if you wish.

    22. Re:Where many people miss the point... by torinth · · Score: 1

      I'm not saying that you, as a savvy user with a fair income, cannot do better by making swap unneccessary for yourself. I totally agree that performance is higher and that therefore it's the preferred way to go.

      But most desktop users are niether savvy or of fair income. They don't have the faintest idea how much RAM they need, and they don't always even have $50 for more RAM. By giving them swap, they can respond to an "out of memory" error by deleting a couple MP3's and increasing their swap space. They don't have to lose an unexpected $50, go to Best Buy, or be a computing genius. It just works.

  6. swap rule! by Coneasfast · · Score: 5, Informative

    the rule is swap should be 1.5x your RAM! ;)

    actually MS followed this rule, in win2k, the default swap size is set to exactly 1.5x your ram, was 176 for my 128mb system, and 384 for my 256mb system, not sure about XP though, someone fill me in
    (yes, some great minds working at MS)

    --
    Marge, get me your address book, 4 beers, and my conversation hat.
    1. Re:swap rule! by Anonymous Coward · · Score: 0

      Yeah, WinXP recommends 1.5GB on my system. I have it set to 0 though. :)

    2. Re:swap rule! by archen · · Score: 1

      I thought it was 2x RAM. Which brings up the point, if I have say 3 Gigs of RAM, do I really NEED 6 Gigs of swap? Hell look at how long it wout take to read 6 Gigs off the hard drive. I agree with the article that swap is probably still neccesary, but perhaps the rule of thumb needs to be adjusted according to usage and needs. Personally I never go over 512M of swap no matter how much RAM I have, but I'm not a kernel hacker either and I have yet to see a good answer concerning when I can make due with a more RAM than swap.

    3. Re:swap rule! by Anonymous Coward · · Score: 0

      I probably should have stated I have 1GB or RAM, so XP still conforms to the 1.5x rule you talked about....

    4. Re:swap rule! by gasgesgos · · Score: 1

      My computer (windows xp) has 1.5gb of RAM, so it has a swap file of over 2gb...
      My roommate has 2gb of RAM, and a 3gb swap file, also using windows xp...
      If he's already got 2gb of RAM, what the hell does he need 3gb of swap space for!?

      windows needs to create swap file sizes inversely proportional to the amount of RAM....

    5. Re:swap rule! by Majix · · Score: 5, Interesting

      The "swap=2x RAM" thing is obsolete admin trivia that simply refuses the die. It comes from the days when physical RAM was mapped into swap to simplify the swapping algorithm. If you didn't have at least a 1:1 correspondence between RAM and swap performance would suffer immensly. Starting with Linux 2.4 and up this is simply no longer true, there is no benefit from using excessively large swap partitions. Same goes for Sun OS and the BSDs these days.

      Instead, the swap needed depends on the sort of usage pattern your machine has. If it's a desktop with 1-3GB of RAM, a swap partition of 1GB is completely adequate. Want the machine to swap as little as possible and utilize all the RAM, so turn down swappiness a bit to avoid Mozilla/Firefox from being paged out when you leave for 15 minutes.

      On a server you need a whole lot more swap, the more the better. Not because it's necessarily any faster, it might be slower in fact with a high swappiness setting the system decides you don't really need that 2GB DB in memory if it's been unused for a month. But when you do run out of memory in legitimate use, the shit will really hit the fan if there isn't enough swap to pick up the slack.

    6. Re:swap rule! by aquasheep · · Score: 1

      I was told that if you select multiple drives for Windows to create swap files in, it will automatically RAID the swap so you get double the performance.

      Unfortunately, when I chose two drives to do this on my system with 1 GB of memory, Windows decided to make 1.5 GB swap drives on each drive, giving me an effective swap file of about 3x my RAM.

    7. Re:swap rule! by Majix · · Score: 5, Interesting

      I forgot to explain swappiness. This is a entry in proc, /proc/sys/vm/swappiness, that you can plug a numerical value between 0 and 100 into. The higher the number, the more eager Linux will be to swap out applications from RAM to disk. There's a lot of conflicting opinions on what values you should use. Kerneltrap had a good article on it recently.

      Personally I use a value of around 20 or less for desktop machines. This keeps Mozilla being paged out after a short while, that really shouldn't be happening on modern hardware. Too bad you can't achieve the same effect in Windows 2000. Some people swear that a swappiness of 0 is ideal for their desktops, your mileage may vary. It's fun to play with in any case, any changes you make take effect instantaneously.

    8. Re:swap rule! by sparkeyjames · · Score: 1

      My inspiron 8200 with a 1.6ghz P4 and a gforce 440 go 32mb video card it is a descent performer and
      I have to admit the swap code execution in windows Xp sucks and I mean sucks bigtime on this system. I have a the a sytem setup with WinXp pro and Slackware Linux. Sometimes I use it to play games (unreal tournament 2004). When going from the game to the desktop the system take 4 minutes to recover under WinXP (yes I have timed it). The system has 512mb of memory and a 1gb swap under WinXp. Granted the 4200 rpm drives have a little bit to do with this problem. Linux however NEVER EVER takes this long for anything and that includes playing UT 2004. I run it under linux too and the recover time is less than 30 seconds. The linux system only has 512mb of swap. Let me say this one more time Windows XP swap code sucks.

    9. Re: swap rule! by Black+Parrot · · Score: 1


      > I thought it was 2x RAM.

      It depends entirely on your work habits (and your RAM). For my first several years I hardly used my Linux swap file at all. But my work habits have changed, and I now have a huge swap requirement.

      Run gkrellm or some other monitor that shows your swap usage. It might be too late for your current system, but it will tell you whether to make a larger or smaller swap partition for your next one.

      --
      Sheesh, evil *and* a jerk. -- Jade
    10. Re:swap rule! by Anonymous Coward · · Score: 0

      > If you didn't have at least a 1:1 correspondence between RAM and swap performance would suffer immensly.

      Windows still likes to have a 1:1 setup, and I think Linux 2.6 will take advantage of it if you've got it.

    11. Re:swap rule! by Admiral+Burrito · · Score: 5, Informative
      so turn down swappiness a bit to avoid Mozilla/Firefox from being paged out when you leave for 15 minutes.

      I think there is a common misconception about how virtual memory works in modern OSs. That is that if the VM writes a page to swap space, you have to wait for it to read it off the disk before you can use it again. That is not necessarily so.

      VMs may write pages to swap and still leave the page in RAM. The swapping is a pre-emptive measure, so that if it really does need to free that memory for other purposes later on it doesn't have to to swap it out to disk, because it is already done. Modern VMs will write pages to swap during idle periods for exactly this reason. If you really do have enough physical RAM, then the VM will never need to repurpose that page of RAM, and it can use the page from RAM without reading back from swap.

      In your hypothetical example the VM may write pages from your browser's process to swap, but when you get back to your desk you shouldn't notice, because the pages will still be in RAM.

      The only reason to turn down swappiness is if you are a victim of that misconception, or if you want to avoid disk activity during idle periods (like, on a laptop where the hard disk is set to spin down after inactivity).

    12. Re:swap rule! by Anonymous Coward · · Score: 0

      The thing is, even with gigs of RAM Mozilla will be swapped out by default after a period of inactivity in Linux 2.4 and 2.6, it's a quite common gripe. The computer then grinds for a good 30 seconds before you can restore your browser. IMO this is due to a too high by default swappiness.

    13. Re:swap rule! by kasperd · · Score: 1

      if I have say 3 Gigs of RAM, do I really NEED 6 Gigs of swap?

      Maybe you don't need it. But it doesn't hurt either. Disk space is cheap. I configure my computers with lots of swap space just in case. I have often allocated 6GB for swap on computers with a lot less RAM than you have. I have one computer with 256MB of RAM and three harddisks. I have a 2GB swap partition on each harddisk. (The rest of the disk space is used for a raid-1 system partition and a raid-5 data partition.)

      --

      Do you care about the security of your wireless mouse?
    14. Re:swap rule! by Anonymous Coward · · Score: 0

      This is probably because even when you're away from the computer a ton of stuff is still running. Misc. cron jobs, updatedb, slocate, daemons etc. Perhaps what's needed is a user space daemon that could give hints to the kernel about application usage patterns.

      A simple desktop policy might look like this: Never page out <your-fav-browser>, don't put files opened by mplayer/xine/updatedb into the disk cache etc. This would improve the impression of responsinvess quite a bit and also free up memory for disk caches of actually useful stuff.

    15. Re:swap rule! by Tiro · · Score: 2, Informative
      You got me to look in /proc for said file, then I thought you tricked me! but it really does exist. Only it wasn't added until 2.6 & some of us still run 2.4

      I'd never used files in proc before so I had no idea if such a beast existed.

    16. Re:swap rule! by Anonymous Coward · · Score: 0

      Er, the first thing you do on a newly installed windows system is set the swapfile to a fixed value, which you choose yourself. Otherwise, Windows will change the size of your swapfile dynamically, which is slow in itself, but worse, it can cause the swapfile to become fragmented, which is BAAAD.

    17. Re:swap rule! by register_ax · · Score: 1

      it seems it's at 60 by default

    18. Re:swap rule! by joib · · Score: 1


      The "swap=2x RAM" thing is obsolete admin trivia that simply refuses the die. It comes from the days when physical RAM was mapped into swap to simplify the swapping algorithm. If you didn't have at least a 1:1 correspondence between RAM and swap performance would suffer immensly. Starting with Linux 2.4 and up this is simply no longer true, there is no benefit from using excessively large swap partitions. Same goes for Sun OS and the BSDs these days.


      Actually, IIRC, the early 2.4 kernels where the only kernels in Linux history that used this sort of swapping algorithm. When the VM was changed in 2.4.10 this behaviour changed back to the old behaviour.

      As to whether 2x RAM is a good rule or not, for most uses it's perhaps a bit excessive, but OTOH with harddrives selling for about EUR 0.6/ GB, who cares?

    19. Re:swap rule! by yoshi_mon · · Score: 1

      You got me to look in /proc for said file, then I thought you tricked me! but it really does exist. Only it wasn't added until 2.6 & some of us still run 2.4

      Indeed. Some of still run 2.2 even!

      2.2.x kernel:

      # ls /proc/sys/vm/
      bdflush buffermem freepages kswapd overcommit_memory page-cluster pagecache pagetable_cache

      2.4.x kernel:

      # ls /proc/sys/vm/
      bdflush kswapd max_map_count max-readahead min-readahead overcommit_memory page-cluster pagetable_cache

      Now if I'm not mistaken all of these values can be tweaked to better improve swap settings. And I think the one to change was kswapd but it has been some time since I messed with it. However I'm sure Google could dig up some info on exactly how to modify each of these settings properly.

      --

      Really, I know what I'm doing...Ohhhh, look at the shiny buttons!
    20. Re:swap rule! by Corydon76 · · Score: 1

      Nope, can't help past 4GB. That's the maximum addressable on a 32-bit system. Any allocation beyond that is wasted space (if you can call 2GB wasted space on a 200GB drive, that is).

    21. Re:swap rule! by Anonymous Coward · · Score: 0

      "VMs may write pages to swap and still leave the page in RAM."


      They may, but Linux doesn't or people wouldn't be complaining about the lag as Mozilla or OpenOffice get hauled back in.

    22. Re:swap rule! by Scooby+Snacks · · Score: 1

      Yeah, well, it kind of helps if you're running a kernel that actually has the feature in question, like, oh, 2.6.

      --

      --
      Runnin' around, robbin' banks all whacked on the Scooby Snacks...
    23. Re:swap rule! by Anonymous Coward · · Score: 0

      "Mozilla thrashes for 30 seconds coming out of swap" is an issue with Mozilla -- see bug 76831.

    24. Re:swap rule! by Foolhardy · · Score: 1

      Yes, the virtual address space is 2^32 or 4GiB. However, modern operating systems (both Linux and WinNT) provide a seperate address space for each process. Each process is limited to 4GiB of total address space (don't forget kernel space too), but the entire system is usually limited to 64TB.

    25. Re:swap rule! by kasperd · · Score: 1

      Actually the limit is 3GB per process because one GB is used for the kernel. That means that even if one process goes wild and allocates the maximum of 3GB, and then forks, my 6GB of swap will still be enough. (Not that it ever happened to me).

      --

      Do you care about the security of your wireless mouse?
    26. Re:swap rule! by Anonymous Coward · · Score: 0

      I've never seen this. The only time I see Mozilla or OpenOffice.org swap is after running a game (like NWN or UT200x) that really does use a lot of memory. This is with 2.4 kernel, 512 MB RAM, 512 MB swap.

    27. Re:swap rule! by julesh · · Score: 1

      Too bad you can't achieve the same effect in Windows 2000

      Damned straight. I was doing some intensive I/O stuff on my Win2K workstation the other day, and it popped up a 'your system is running low on virtual memory' warning box. I had a look at the usage - about 35Mb of application data, 30Mb of kernel data and the other ~200Mb was disk cache!

    28. Re:swap rule! by julesh · · Score: 1

      They may, but Linux doesn't

      Linux does, and has done for a long time - look at the stats displayed by 'top'. You'll see information on memory used, free, buffered and swap used, free and cached. Cached is the number of pages that have been swapped out but not reused yet. (Buffered is the size of your disk cache.)

      It just does other things as well. Setting swappiness low controls how likely file cache is to replace application data, which is probably the problem you're encountering.

  7. no swap? by hawkeyeMI · · Score: 3, Interesting

    I ran linux without a swap file on 128 MB of memory a couple of years go. It was an accident, I didn't create a swap partition. I never had a problem (forutnately). Of course, I wasn't doing the heavy duty stuff I am now (scientific computation).

    --
    Error 404 - Sig Not Found
    1. Re:no swap? by hawkeyeMI · · Score: 1

      Oh man the typos are killing me... should have previewed.

      --
      Error 404 - Sig Not Found
    2. Re:no swap? by Gadzinka · · Score: 1

      I accidently did the same on 64M production server of my customer (dns, gw, email). It didn't work perfectly, once in a couple of weeks some named subprocess died leaving the rest inoperable, but they were heavily conditioned by windows they use to reboot machine when something doesn't work.

      I've noticed it only after installing snmpd on all customers' machines managed by me and running snmpdf on all of them -- one machine was standing out with swap total 0, used 0 ;) It was working this way for almost three years.

      Robert

      --
      Bastard Operator From 193.219.28.162
    3. Re:no swap? by Pig+Bodine · · Score: 1

      In my experience for many types of scientific computation if your code runs into swapping you are in trouble. For highly tuned code in numerical libraries people even worry about L1 and L2 cache utilization.

      I have been recently working on a code for solving linear systems of a specific structure (Toeplitz for those who care about such things). The algorithm I'm using solves smaller linear systems of size 256-by-256 as a core operation. Many of the smaller systems have the same system matrix but different right-hand-sides. I got clever and decided to store information (the Cholesky factor) of these systems to speed up their solution. This completely messed up the use of cache and I saw a big drop in performance. Another time I tried running this "improved" code on my 128M laptop. It hit swap and probably would have run forever (certainly longer than I had any patience for).

    4. Re:no swap? by Odin's+Raven · · Score: 1
      I ran linux without a swap file on 128 MB of memory a couple of years go. It was an accident, I didn't create a swap partition.

      If you ever do find yourself in need of swap space sometime in the future, remember that swap doesn't have to be a partition - you can also swap to a file. Swapfiles aren't quite as efficient as partitions, but they're easy to set up, and you can add them to a system without repartitioning. Heck, you don't even need to reboot. All you need is free space on your existing filesystem.

      This is a handy way to add permanent swap to a previously swapless machine. It's also useful on machines with a dedicated swap partition if you discover that you allocated too little swap for your needs. Or even if you just need some extra swap space on a temporary basis, perhaps to run a memory-hungry program for a couple of weeks for a project or class.

      On most Linux distros, you can find info on this in the mkswap(8) manpage. If you don't happen to have the manpage (a common enough circumstance with servers), the general outline for creating a 512MB swapfile is as follows:

      • dd if=/dev/zero of=/path/to/swapfile bs=1M count=512
      • mkswap /path/to/swapfile
      • swapon /path/to/swapfile

      Voila. You now have 512MB of swap available.

      If this is going to be a long-time/permanent addition to your system, you'd want to add this to /etc/fstab so that it's automatically remounted whenever you reboot the machine, which you can do by adding an entry like:

      /path/to/swapfile swap swap defaults 0 0

      If you don't add the swap file to fstab, just remember to do the swapon /path/to/swapfile command after you reboot the system.

      If this was a temporary swapfile, when you're all done you can clean it up by doing:

      • swapoff /path/to/swapfile
      • (remove /etc/fstab entry if you added one)
      • rm /path/to/swapfile

      Final note: Always be realistic, folks. Swap's useful in many cases, but it's not a magic bullet. If a program needs significantly more memory than your physical RAM, it's going to take a massive performance hit. If you'll be running something that needs that much memory on a regular basis, bite the bullet and buy more RAM. Or for short-term needs with memory-hungry applications, you might be better off finding the friendly neighborhood uber-geek (the one with the 16GB quad-Opteron machine) and trading a couple of pizzas for some runtime on a better-equipped machine.

      --
      A marriage is always made up of two people who are prepared to swear that only the other one snores.
    5. Re:no swap? by hawkeyeMI · · Score: 1

      I have modpoints, too bad I can't mod comments to my own post. This would get a +1 informative!

      --
      Error 404 - Sig Not Found
    6. Re:no swap? by ShakaUVM · · Score: 1

      >For highly tuned code in numerical libraries people
      > even worry about L1 and L2 cache utilization.

      It's not "even worry" -- optimizing the use of the cache is about the biggest issue in developing high performance codes. =)

      I worked in the high performance lab at UC San Diego for years, and we'd typically run hundreds of benchmarks every time we moved to a new machine so that we'd know what sort of parameters would give the best performance based on the real-life (not the published theoretical speeds that are so useless :) performance of cache, network bandwidth, network latency and computation speed.

      -Bill Kerney

  8. Swap space not needed.... by kidgenius · · Score: 4, Funny

    If you've got 128MB of RAM you have plenty and therefore will have no need for swap space. I mean, isn't 640k enough for everyone?

    1. Re:Swap space not needed.... by Coneasfast · · Score: 4, Insightful

      isn't 640k enough for everyone?

      people constantly make this joke, but seriously, at the time BG said this, it was probably true.

      if today i say "1 gig ought to be enough for everyone" it is true, but in 10 years from now you will be laughing at this.

      he never claimed it would 'ALWAYS' be enough (unless there is more to this quote???)

      --
      Marge, get me your address book, 4 beers, and my conversation hat.
    2. Re:Swap space not needed.... by Anonymous Coward · · Score: 0

      If 1 gig ought to be enough for everyone (I presume you mean anyone), then why are there computers out there with 8TB+ RAM today?

      You think they are just waiting for Windows(c)(r) Special(c)(r) HPC(c)(r) Super-Friends(c)(r) BSOD(c)(r) Matrix Reloaded(c)(r) Cool(c)(r) 2010(r)(c) Edition?

    3. Re:Swap space not needed.... by Anonymous Coward · · Score: 0

      exactly, it was a lack of vision.
      which is not a big deal.
      who would have even comprehended the future of computers like its today.

      i dont care if he said it. big deal. it was fitting for the time.

      its easy to look back and say somone was stupid for a comment predicting the future.

      (supposidly he didnt, but i think thats just cover, but it doesnt matter either way to me, it was a valid comment for the time)

    4. Re:Swap space not needed.... by EvanED · · Score: 2, Insightful

      I doubt it was even that much a lack of vision. You *have* to make a limit somewhere, you can't make, for instance, addresses an infinite number of bits. Now, maybe they were too shortsighted in picking 640K (which actually doesn't make sense to me as it's not a power of 2, but I guess I don't know enough about the reasoning), that's something to pick. But eventually, yes, people would turn around and laugh at it.

    5. Re:Swap space not needed.... by Anonymous Coward · · Score: 0

      > at the time BG said this, it was probably true

      Yeah, but 10 years later people were still fighting with the 640K Problem and wanted to blame someone, so they invented this quote. (When they should have blamed themselves for not running OS/2 or NT or Unix.)

    6. Re:Swap space not needed.... by Anonymous Coward · · Score: 0

      Keep in mind that back then, there was a huge difference between a "microcomputer" and a "real computer" -- unlike today.

      In context Gates would have meant "ought to be enough for anyone using a PC. If it's not enough for you, buy a VAX."

    7. Re:Swap space not needed.... by Anonymous Coward · · Score: 0

      And then there's this little fact that he probably never said it. But hey, who's counting? Seriously, people have pointed out this story's urbanlegendness many many times.

    8. Re:Swap space not needed.... by pantherace · · Score: 2, Interesting
      As I recall (it hasn't been recently) The chips that were designed had the capability to address 1MB of RAM (8088 & 8086). IBM reserved the top 384KB or so for ROM & system calls. So the person was left with (1024KB-384KB) 640KB for using as actual RAM.

      That's part of the reason why the 4GB addressing limit matters, and really x86 is hurt badly performance wise if you have more than a GB or 2, even below the physical 4GB limit (which can be extended via Intel's extensions (this limit doesn't exist in native AMD64, or Intel's semi-copy of that.)): now x86 relies on paging & virtual memory spaces, with upper addresses reserved for libraries, & kernel calls. This mapping may take up a fair amount of space, and when manipulating large data sets (very large images, Databases & other stuff)... this becomes problematic, because of the virtual 4GB limit. The physical limit may not have been reached, but the virtual limit is. Doesn't mean more RAM isn't faster, but it does mean that there is a speed hit in some cases.

      If Bill Gates said it (he has denied it, but it's been around a LONG time), it may have even been something resigned possibly preferenced with an "Oh well, " or something like that.

    9. Re:Swap space not needed.... by Anonymous Coward · · Score: 0

      which actually doesn't make sense to me as it's not a power of 2

      1024 is, MS-DOS needed quite a lot so that only 640k was left for running applications.

    10. Re:Swap space not needed.... by MrMr · · Score: 1

      You *have* to make a limit somewhere, you can't make, for instance, addresses an infinite number of bits

      But that's exactly the point, not only is infinite impossible, but any finite value larger than that chosen had become a head-ache.
      By the backward design of the memory space (the maximum possible address =1Meg, and we count backwards to zero) make simple expansion of the 20 used bits on the potentially 32 bits address bus impossible.
      At the time memory size growth in all computers was progessing at the same rate as now. The stupidity of this design choice is of a stalinistic magnitude. Many thousands of good people wasted years of their lives in untold suffering (that is, programming for DOS) repairing the damage done.

    11. Re:Swap space not needed.... by KaledZeCamel · · Score: 1

      The quote is : "640K is more memory than anyone will ever need."

      But Bill Gates denies having said it.

      Who knows the truth ?

    12. Re:Swap space not needed.... by Nukenbar2 · · Score: 0

      This dumb joke will ALWAYS be around.

    13. Re:Swap space not needed.... by Almond+Tree · · Score: 0

      640K (which actually doesn't make sense to me as it's not a power of 2

      So 640 is an odd number now?

      --

      bau bau chicka chicka mau mau

    14. Re:Swap space not needed.... by psetzer · · Score: 1

      I wouldn't get on Bill's case too much on this. The Intel could only handle that much RAM. He was hired to make an OS for it, so he was stuck with that decision wether he liked it or not. The choice for only 20-byte addressing was simple. It saved on the size and cost of the chip, and it saved memory bandwidth. 64-bit processors have pointers that are 8 bytes long, rather than the current 4 byte pointers. That means that cache has a smaller effective size, the TLB is larger, and a whole host of little things that make the processor more expensive. Remember how expensive they were back then? They'd be even more so with the ability to access more memory, and that would have really hurt the sales of the fledgling personal computer industry.

      --
      "Anyone who attempts to generate random numbers by deterministic means is living in a state of sin." -- John von Neumann
    15. Re:Swap space not needed.... by Anonymous Coward · · Score: 0

      Power of 2, not multiple of 2.

    16. Re:Swap space not needed.... by pilsner.urquell · · Score: 1

      Try this exercise -- $ swapon -a, $ swapoff -a

  9. Yes, It's Necessary by rsmith-mac · · Score: 3, Insightful

    As long as users can eat up more memory than they have available, and as long as hard drive space is cheaper than RAM space, swap will always be necessary.

    1. Re:Yes, It's Necessary by Waffle+Iron · · Score: 1
      I think that the main benefit of swap space is that it acts like those energy absorbing crash barriers that they put in front of highway bridges. You try not to drive into them, but if you do, at least you slow down gradually.

      Likewise, once you start swapping heavily, using your computer can become almost unbearable, but at least your apps don't crash. Usually it means that it's time to pick some apps and close them so get your computer back within its memory capacity running full speed.

      Swapping is kind of a signal that reminds you: Don't try to simultaneously boot 3 sessions under VmWare until you buy some more DRAM.

  10. On a laptop... yes, for the wrong reason by robbo · · Score: 0

    Goddammit I can't suspend my laptop because my swap partition is insufficient in size. Why should I have 2 GB of disk space *empty* all the time just so I can close the lid.

    Someone please fix acpi hibernate to do something sane...

    --
    So long, and thanks for all the Phish
    1. Re:On a laptop... yes, for the wrong reason by whiteranger99x · · Score: 2, Informative

      Yeah, because God forbid you should have to use the SAME amount of disk space as the ram you have installed to save a few seconds to bring the laptop up :P

      --
      Join the TWIT army now!
    2. Re:On a laptop... yes, for the wrong reason by robbo · · Score: 2, Interesting

      It's all diskdrake's fault. I didn't choose my swap size, afair, although it's weird it's smaller than my RAM. Beyond that, acpi recommends you have swap about 30% larger than your RAM. While it would slow down the suspend, I don't see why acpi doesn't pipe /dev/mem through bzip first, or for that matter, why hibernate can't just dump to a file.

      --
      So long, and thanks for all the Phish
    3. Re:On a laptop... yes, for the wrong reason by kayen_telva · · Score: 1

      there is nothing "informative" about the parents post and the GP has a valid point.
      surely the contents of ram can be compressed ?

    4. Re:On a laptop... yes, for the wrong reason by Anonymous Coward · · Score: 1, Informative

      I don't know if it works for SWSUSP (the hibernation driver), but you can actually swap to a file under GNU/Linux. You can add and remove swap files while the system is running, so you might even be able to add a power management script that creates and formats a swap file right before hibernating, and deletes it after unhibernating.

    5. Re:On a laptop... yes, for the wrong reason by whiteranger99x · · Score: 1

      Duh! See, that's what I get for posting late at night, I don't even think of obvious shit like compression.

      Anyway, I'm assuming that DiskDrake took into account that you were only using that space for swap space, as opposed to storing it in hibernation. I'm not too sure how ACPI is implemented on linux, due to the fact that my computer is old :)

      --
      Join the TWIT army now!
    6. Re:On a laptop... yes, for the wrong reason by Anonymous Coward · · Score: 0

      > why hibernate can't just dump to a file.

      Swap Partitions are a legacy habit on Linux. Back in the 2.2 era, swap files were really slow, so you were supposed to dedicate a fixed size partition.

      Now, there's almost 0 performance difference, and desktop distros like Mandrake should probably use a swapfile instead of a partition. In fact, you can just add a file, you aren't stuck with diskdrake's decision.

      bzipping 1GB of memory would be pretty slow, no?

  11. speaking of which by MasTRE · · Score: 1

    Does anybody have experience with running swapless Linux servers? I am looking for a best practices for setting memory and virtual memory limits (presumably, using ulimit). Can setting soft (ulimit -aS) and hard (ulimit -aH) limits guarantee that your programs will not eat up all of the system's RAM and cause an OOPS? I'd love to hear about your experiences.

    --
    Must-not-watch TV!
    1. Re:speaking of which by wotevah · · Score: 1

      When a process tries to eat more RAM than is available, the kernel will not panic and will calmly kill the bad process.

    2. Re:speaking of which by Anonymous Coward · · Score: 0

      The kernel doesn't kill processes that try to "eat" too much RAM; it just won't let them allocate any more pages. That may be different with a hard ulimit, but it sounded like you were saying that's not necessary.

      aQazaQa

    3. Re:speaking of which by wotevah · · Score: 1

      You can allocate more memory than is available. When you try to use all of it your process will get killed.

    4. Re:speaking of which by Anonymous Coward · · Score: 0

      What are you guys saying? Does malloc return null? Obviously if you try to access 0x00000000 your process will be killed. The app should be able to catch that though.

    5. Re:speaking of which by MasTRE · · Score: 1

      Any of you know of a practical guide to using ulimit, specially as it applies to swapless boxen? I would very much like to know what best practices are. For example: given you have X RAM, what should you set the various hard/soft limits at? This would obviously vary from application to application, but it would be great to see what others have experimented with.

      --
      Must-not-watch TV!
  12. Swap nessisary in low mem (128M) systems by strredwolf · · Score: 4, Informative

    Swap improving performance... yeah. On slow systems and low memory, every byte freed up helps. But not swapping in the first place is good too.

    I'm now expermineting with replacing various tools with smaller versions, such as dropbear, udhcp, tinylogin, and buzybox. I'm also slowly writing up a "exec and restart shell afterwards" utility called PivotShell.

    Hardware wize, I have swap on a CF drive. 32 megs so far, but if I can afford larger CF drives, I'll format 'em as swap and use them.

    Why all of this? 40 megs swaps to HD, and on a laptop, any HD access sucks battery power. When you're using Xfree (or even Kdrive) and Firefox, you're going to swap. Period.

    --

    --
    # Canmephians for a better Linux Kernel
    $Stalag99{"URL"}="http://stalag99.net";
    1. Re:Swap nessisary in low mem (128M) systems by BiggerIsBetter · · Score: 4, Informative

      Don't do that. CF has a limited number of write cycles (100,000 or so, typically), and swapping to it will kill it quite quickly.

      --
      Forget thrust, drag, lift and weight. Airplanes fly because of money.
    2. Re:Swap nessisary in low mem (128M) systems by beerits · · Score: 1

      Doesn't Compact Flash have a limited number of write/rewrite cycles? I would think using it for swap would burn through those cycles very quickly.

    3. Re:Swap nessisary in low mem (128M) systems by jrockway · · Score: 1

      Yes. I have a GCT, and don't even let the thing mount the CF read/write. I get the system bootstrapped off of the CF and then get everything I need off of NFS. Much safer :)

      If you want swap, swap to NFS is feasable though (and if you have gigabit, the link can outpace the remote disk anyway). I've never tried it because I have 256M of RAM in the thing (and it only runs a local xserver; everything else runs on the server).

      --
      My other car is first.
    4. Re:Swap nessisary in low mem (128M) systems by CAIMLAS · · Score: 1

      You're rediculous to be trying to use firefox on a machine with 128Mb of RAM and no physical disk swap.

      i'd not say that, if it weren't for the fact that CF media only has so many writes before it starts to die, and it's waaaay too expensive to use for such purposes. It depends on the manufacturer, but it's certainly not enough writes to use for swap consistently.

      Plus, CF is slow.

      --
      ~/ssh slashdot.org ssh: connect to host slashdot.org port 22: too many beers
    5. Re:Swap nessisary in low mem (128M) systems by Alternate+Interior · · Score: 1

      Isn't CF incredabily slow? I've used a 128MB card on USB2.0 for a maildir and there was delay (drastic on one system, noticeable on another) whenever reading/writing from/to it. Swaping has got to me more disk-intensive than writing and opening emails.

    6. Re:Swap nessisary in low mem (128M) systems by strredwolf · · Score: 1

      This is on a laptop where you have more direct access to the CF card (via a PCMCIA adapter).

      I know, I'm burning up the CF card. Anyone know where I can find a ramdisk-in-a-PCMCIA card?

      --

      --
      # Canmephians for a better Linux Kernel
      $Stalag99{"URL"}="http://stalag99.net";
    7. Re:Swap nessisary in low mem (128M) systems by GrenDel+Fuego · · Score: 1

      and if you have gigabit, the link can outpace the remote disk anyway

      Gigabit ethernet might give you enough bandwith for swapping, but the latency will kill you.

    8. Re:Swap nessisary in low mem (128M) systems by andrewgaul · · Score: 1
      Gigabit ethernet might give you enough bandwith for swapping, but the latency will kill you.
      Huh? Hard drive seek times are 5-15 ms. 100 Mbit Ethernet round trip times are about 0.2 ms. Myrinet can bring that down to about 0.01 ms.
    9. Re:Swap nessisary in low mem (128M) systems by julesh · · Score: 1

      Yes but, then there's latency in the server process to consider as well. I'm not sure about modern systems (my file server is getting fairly ancient), but latency on file accesses over network are typically about 2-3x the equivalent for local accesses. (100Mbit hub-based network with 3 workstations accessing infrequently, file server is samba on linux 2.4 with ext3 fs running on P166MMX + 128Mb RAM, local file access is ntfs on win2k with a 350MHz PII and 256Mb RAM)

  13. Swap can save your ass by Julian+Morrison · · Score: 4, Interesting

    Sometimes, when a process goes haywire, it will start munching RAM. If important programs like, say, sshd or X, can't malloc when they need to, they'll die ignominiously. Swap gives you the chance to kill the rogue process before your OS goes kaput. Its slowness can actually help for this.

    1. Re:Swap can save your ass by robbo · · Score: 1

      Once upon a time, like kernel 2.0, rogue processes would go haywire, consume all available memory (and swap), and then die quiet deaths without any real effect on system stability. When 2.2 came out, I remember submitting a bug because rogue processes could render the entire system unstable by consuming all the ram and swap. I haven't tried it on 2.4 or 2.6, but I remember the bug was squashed as NOTABUG.
      One would think that ensuring system stability against such a simple DOS attack would be a priority.

      --
      So long, and thanks for all the Phish
    2. Re:Swap can save your ass by Anonymous Coward · · Score: 0

      No, the 2.0 kernel can't magically make swapping efficient.

      More likely, as the gap between RAM size and harddisk speed vastly increases, you simply noticed the increased impact of having all your memory swapped out.

      ulimits are what you are after.

    3. Re:Swap can save your ass by anshil · · Score: 4, Informative

      Thats not true, if the linux kernel gets out of memory it takes the list of all processes, scores them with memory usage, runtime etc. and then simply kills the process of highest score. In your case your RAM munching app. would just be killed by the kernel.

      I know that pretty for sure, since I modified that part of the kernel once for an embedded system, where we explicitly didn't want it to kill any process, but have instead to reboot in such a case. Since nothing is worse than having a half-functional system with some processes missing....

      --

      --
      Karma 50, and all I got was this lousy T-Shirt.
    4. Re:Swap can save your ass by arjun · · Score: 1

      yup. you are right. look at mm/oom_kill.c:badness() to get the actual details.

    5. Re:Swap can save your ass by Kjella · · Score: 1

      I know that pretty for sure, since I modified that part of the kernel once for an embedded system, where we explicitly didn't want it to kill any process, but have instead to reboot in such a case. Since nothing is worse than having a half-functional system with some processes missing....

      Most systems are half-functional already ;) And yes, there's nothign worse than that, but it usually has nothing to do with processes dying...

      Kjella

      --
      Live today, because you never know what tomorrow brings
    6. Re:Swap can save your ass by groomed · · Score: 1

      Actually the real problem is that the kernel will sometimes grant memory requests that it cannot fulfill. So it can happen that malloc() returns a block of memory to the application, but as soon as the application tries to use the allocated memory, the kernel kills it, since the memory just isn't there. Allegedly this can be fixed/tuned via /proc/sys/vm/overcommit_memory, but it's hit-and-miss really. The accounting is just not reliable.

    7. Re:Swap can save your ass by Alien+Being · · Score: 2, Insightful

      The parent, was talking about processes "munching RAM", not VM.

      On a system with no swap, all of VM would be exhausted very quickly by a runaway, at which point the behavior you're describing would kick in. But on a system *with* swap, IO waits act like a brake. In some cases it gives the admin time to stop the runaway train before it hits the wall (no more VM).

    8. Re:Swap can save your ass by DunbarTheInept · · Score: 1

      Okay, so let's say you have X ram plus X swap. This means programs will die when you have 2*X memory used. How is this an improvement over having 2*X ram plus no swap, in which case programs will still die when you have 2*x memory used, but it will be over and done with faster, instead of being agonizingly slow while you are trying to root around finding the problem and being unable to get anywhere because it's taking over a minute to do a simple "ps aux".

      People are speaking in terms of "I have X ram plus Y swap". For the sake of this question, look at it this way - you actually have X+Y amount of memory - but some of it is slow and some of it is fast. If there is a circumstance where this is an advantage over having X+Y of fast memory and none of the slow kind, then that means something is seriously wrong with the way the system is managing memory.

      It's been my experience that by the time I notice a system is swapping like mad and therefore I should check to see if a process is eating too much memory, the performance is so terrible that my machine might as well have crashed altogether - at least then I could reboot, wait for fsck, and be back up and running, instead of it taking agonizingnly long to wait for the simplest of commands to finish while I try to discover the problem, and be frustrated that it's taking several minutes for a simple 'ps' command to run, and eventually I give up and reboot anyway.

      The situation you speak of would only happen if a runaway process is eating memory *slowly* - slowly enough that you can start to detect a slowdown because of swap but still be able to use the system for a while before it gets really bad. That generally doesn't happen to me. Usually the onset of the memory eating is fast enough that by the time I notice, the system has already gone from usable to so slow I might as well reboot, and it only took a matter of less than 30 seconds to that state.

      --

      Don't label something "offtopic" unless you know the topic well enough to tell what's on topic.

    9. Re:Swap can save your ass by DunbarTheInept · · Score: 1

      Actually, what would be nice would be a way to reserve something like 1 or 2 percent of the RAM for the use of programs launched by one special rootlike user (user with uid 0, but not called 'root' - called something like "emergency" or something). This would be the safety net so that there was a way to do something about a system that was swapping like mad. The "emergency" user would always have a little sliver of actual ram guaranteed to exist for him and nobody else - for the purpose of logging in and running a shell and a few diagnostic commands. For a server environment where uptime is important, I'm sure a lot of sites would be willing to sacrifice the use of a few Mb of ram for this assurance, still leaving 98% of the system's ram for everything else.

      --

      Don't label something "offtopic" unless you know the topic well enough to tell what's on topic.

    10. Re:Swap can save your ass by DunbarTheInept · · Score: 1

      So, basically, all those lines of code spent on checking the return value of malloc were a total waste of my time? That's disappointing.

      --

      Don't label something "offtopic" unless you know the topic well enough to tell what's on topic.

    11. Re:Swap can save your ass by anshil · · Score: 1

      Actually not, if you read the parent you'll notice he pointed out that a runaway process would endanger the whole system, and hinder *other* processess. This is not case.

      --

      --
      Karma 50, and all I got was this lousy T-Shirt.
    12. Re:Swap can save your ass by Alien+Being · · Score: 1

      The scoring heuristic you described is not perfect. Healthy processes are endangered any time there's a shortage of VM regardless of which process or processes caused it.

    13. Re:Swap can save your ass by anshil · · Score: 1

      I know it isn't perfect, but in a case of a process going harvast and eating eat all VM up, it will be the one to be killed, very sure, nothing endagered, POINT!

      (excerpt from oom_kill.c) /*
      * The memory size of the process is the basis for the badness.
      */
      points = p->mm->total_vm;

      --

      --
      Karma 50, and all I got was this lousy T-Shirt.
    14. Re:Swap can save your ass by Alien+Being · · Score: 1

      "I know it isn't perfect, but in a case of a process going harvast and eating eat all VM up, it will be the one to be killed, very sure, nothing endagered, POINT!"

      The badness() func in 2.4.22 uses these factors: psize, cputime, runtime, is_superuser, and is_nice.

      So consider a system that starts a large database server and an instance of a db client program at boot time. The db server allocates a bit less than half of VM. After a while, the client program goes crazy and eats up the remaining VM.

      Assume:
      The client becomes as large as the db server.
      The runtime of the 2 procs is the same.
      is_superuser == 0 for both procs.
      is_nice == 0 for both procs.

      cputime becomes the deciding factor, and it isn't a longshot that the db server will have used fewer cycles than the runaway client. The db server would be killed.

  14. You've some good points... by robslimo · · Score: 5, Interesting

    but today's production, heavily loaded system will still need the ability to swap to/from disk.

    Already, there are systems that minimize that need, set-top boxes, embedded systems in general. But each of those is seriously modified (kernel-wise, mostly) to achieve the responsiveness, the frugality of resource treatment that a general purpose desktop computer can't expect to enjoy.

    That doesn't mean that developers should stay in the same rut, assuming that hardware that confined system design in the '60s, '70s... '00s will perpetually assign similar constraints.

    IMO, desktops still need to swap... for now. but let's not paint ourselves into a performance corner.

    1. Re:You've some good points... by Goldberg's+Pants · · Score: 5, Interesting

      If you've just got a box sitting not doing much, in other words not serving pages, SQL or whatever, you can run with minimal ram. My laptop has 24 megs of ram. I did have a 100 meg swap partition, but needed the space for a particular huge DOS game I wanted installed, so nuked it and converted it to DOS. Booted Linux and checked the ram usage and most of the ram was used.

      However, when I ran a program, the amount of used ram DROPPED.

      Of course in an environment where the system gets hammered, it's all very well talking about how cheap ram, but so is hard disk space. Is it really worth not setting up a bunch of swap space? What if a rogue process munches it's way through the ram while you're away? Would it not be better to have swap space and have it so the system can run, albeit not very well, than just die on you?

      I don't know, I ain't a sys admin, but performance issues aside, I don't see why you should risk it. I'd rather have swap partitions on a hardcore system than not.

    2. Re:You've some good points... by Proud+like+a+god · · Score: 5, Insightful

      Surely if your system runs out of RAM it shouldn't die? The runaway process, sure, but the OS should be able to reclaim some RAM from that and manage to carry on, no?

    3. Re:You've some good points... by antirename · · Score: 1

      You need swap. I've got 2 gigs of RAM on my work machine and will still use swap occasionally. I'd rather have an program slow down (usually when moving lots of files around) than crash.

    4. Re:You've some good points... by krewemaynard · · Score: 4, Informative

      "...the OS should be able to reclaim some RAM from that and manage to carry on, no?"

      yeah, pretty much. i may be openly admitting my ignorance here, but i have a gentoo box with 256 MB DDR RAM. i set up a swap partition, and set up the entry in /etc/fstab, but when i ran the box, it never touched the swap. me: "great, this RAM ownz! and the 2.6 kernel ownz at memory management! it never uses swap!"

      then, stuff started dying on me during times of heavy system load. like, i'd be in Firefox and running emerge at the same time, and firefox would croak on me. or VMWare wouln't boot Knoppix. or OpenOffice would die. all this time i had something else going on on top of whatever memory-intensive program was dying. me: "wtf, mate?"

      it finally occurred to me that the box still wasn't swapping, and that might be a bad thing. so i tried to run "swapon /dev/hdb2" (my swap partition) and got errors. weird. then i realized what happened...

      ...i had forgotten to officially make the swap partition using mkswap. i'd been running this partition schem for about 2 months, and never realized it until about 2 days ago.

      all that to say, yes. the system DOES reclaim memory. by killing other stuff :)

      i'm a stoopid monkey sometimes :-D

      --
      I saw it on Slashdot, it must be true!
    5. Re:You've some good points... by Anonymous Coward · · Score: 0
      Surely if your system runs out of RAM it shouldn't die? The runaway process, sure, but the OS should be able to reclaim some RAM from that and manage to carry on, no?

      Where did you get the idea that you won't have a memory allocation fail for a totally innocent process once you run low on memory? Perhaps you're thinking the kernel can just kill the runaway process and free up resources before it lets memory allocations fail for innocent bystander processes. But, how does the kernel know *which* process is the runaway process? Hint: it isn't always the one using the most memory or the most CPU. Sometimes you have a program that has a legitimate need to use huge amounts of memory and CPU, and some *other* process goes nuts and takes up the 200 MB of safety margin that was supposed to allow you to run the big program.

    6. Re:You've some good points... by Anonymous Coward · · Score: 1, Informative
      However, when I ran a program, the amount of used ram DROPPED.

      That's because many RAM reporting utilities (and /proc) include RAM used as a cache as "used". This is not quite accurate, since RAM used for the cache will be instantly freed if any program wants it.
    7. Re:You've some good points... by PastaLover · · Score: 3, Informative

      The system only does that when it runs out of unused buffers though. This means that at the time a program has to be killed all of your ram is officially used by processes.

      I think the OP is probably right. I have 512 megs of ram and using my full suite of apps (let's say something like firefox, thunderbird, a seti process, xmms, irssi in an rxvt and maybe some other xterms etc) I'm using about 200 megs of ram (not counting unused pages). So there was no real need for me to have swap since it never, ever gets used (I've never actually tried to fill all the 500 megs up to the full). So on a desktop system, you rarely have enough bloat to actually need swap.

      That being said, I don't understand why a swapping system would be slower than a swapless system, except maybe on bootup when you have one extra partition to load.

    8. Re:You've some good points... by krewemaynard · · Score: 1

      yeah, if i ran with 512, i could probably go without swap too. i have about 500 MB of swap, and seldom touch even 20% of it. if i doubled my RAM, i'd be in good shape.

      --
      I saw it on Slashdot, it must be true!
    9. Re:You've some good points... by Proud+like+a+god · · Score: 1

      Well it's one course of action, though obviously you could use some of the different algorithms used for deciding which pages to swap to determine which process to kill, such as compare the last actively used/ran times, oldest process, smallest/largest process, or pids so root tasks win out.

      You could indeed try a more complex route rather than process-that-is-falling-off-the-end-of-the-system, but that also has benefits, such as being very reproducable on the running system (maybe think embedded OS without swap).

    10. Re:You've some good points... by haggisman · · Score: 2, Interesting

      >>Surely if your system runs out of RAM it shouldn't die? The runaway process, sure, but the OS should be able to reclaim some RAM from that and manage to carry on, no?

      Not Windows XP for sure .. I edited an ISO image using 2 different editors and instead of the editors barfing, XP froze solid each time.

      Scotty

    11. Re:You've some good points... by Anonymous Coward · · Score: 0

      Geez, 100MB, 24MB RAM...
      What was that game, Doom 3?

    12. Re:You've some good points... by Anonymous Coward · · Score: 0

      That was a good "war story". Thanks mate!

  15. Relation to 40h bit computing? by Thinkit4 · · Score: 0

    On one hand you can have a huge amount of RAM. On another, you can have memory mapped I/O. Anyone see the future of this?

    --
    -I am an elective eunuch.
  16. Swap is vital by psetzer · · Score: 1

    Swap files are how we are able to get those $400 computers. I don't have any idea how a modern person can put up with 128 megs of RAM and Windows XP, but some people out there do. Doing without swap is only really feasible if you aren't running many different things on your computer at once, and what you do run isn't as much of a hog as many programs are nowadays. I guess if you were to use as small of a Linux kernel as you could and didn't install X on your computer, it wouldn't be much of a problem and you could do without swap. If you really want to go light on the memory usage, just use ed.

    --
    "Anyone who attempts to generate random numbers by deterministic means is living in a state of sin." -- John von Neumann
    1. Re:Swap is vital by Anonymous Coward · · Score: 0

      Well, in linux I don't need swap except when I am using maya. I generaly use about 50 of my 192 megs. In windows though I definately need it. I turned it off once to get rid of that unmoveable sector when I was repartitioning it. Sickening...

    2. Re:Swap is vital by Doppler00 · · Score: 1

      Doesn't anyone remember the days when we had full graphical user interfaces in less than 8MB of RAM? What's this about needing 128MB of ram? Where did all our memory go?????

    3. Re:Swap is vital by Stevyn · · Score: 1

      Remember how ugly those gui's looked? I remember running windows 3.11 and netscape on 4 megs back in the day. It actually had this problem where it would saturate the system and completely reboot in the middle of browsing.

      Where does the ram go? Well in windows, I don't know. It always seems to disappear with each new version. However, you can see how some applications are really wasteful. I've seen AOL instant messenger take about 25 mb of ram. Photoshop opening large files will take well over a hundred. Explorer, you're talking 20-30. Basically that's 150 without even considering windows, which needs a minimum of 128 to get started. I think developers are taking it for granted because ram is getting cheaper. There is no reason AIM should require so much ram though, that's crazy.

    4. Re:Swap is vital by Zork+the+Almighty · · Score: 1

      Where does the ram go? Well in windows, I don't know.

      Into the damn ether, that's where. For Windows XP, you may want to look at this list of services and turn off as many as you can. It really helped my sister's computer (256MB).

      --

      In Soviet America the banks rob you!
    5. Re:Swap is vital by EvanED · · Score: 1

      AIM 5.5.3415 is at 14MB now... (this is with middle_man addin though, so if there are memory leaks it may not be AIM's fault)

  17. Try this with linux by arvindn · · Score: 4, Interesting

    Notice how sluggish the system is after doing something disk-intensive like watching a movie. That's because the kernel is caching as much of the movie as possible to memory and swapping your running apps out. And kernel developers think this is a good thing, so it isn't going to change any time soon. IMHO for a desktop system this makes no sense, that's why I run my 1GB RAM machines with zero swap.

    1. Re:Try this with linux by Rashkae · · Score: 1

      Actually no,, I agree that it's unfortunate the Disk Cache ends up holding useless data, (like a movie file that gets read once sequentially). But even so, switching tasks is almost always instant. The only problem I've ever encoutered is with applications that eschew senseless amounts of memory. (Like Mozilla or Firebird. The longer those have been running, the longer they will have to swap when I switch back. For Mozilla, I find it necessary to close the application from time to time and restart it to prevent the eventual memory leak from causing swap storms.)

      Besides, if this behaviour bothers you, you can change the value of swappiness to prevent your applications from being swapped out. Overall, however, on most average workloads, the default settings provide the best performance.

    2. Re:Try this with linux by Anonymous Coward · · Score: 0

      with applications that eschew senseless amounts of memory.

      Inigo Montoya: You keep using that word. I do not think it means, what you think it means.

      Do you mean "chew"? Eschew normally means "to avoid or stay away from deliberately". I know my installation of Mozialla does not eschew any of my memory!

    3. Re:Try this with linux by molo · · Score: 1

      In Linux 2.6, you want to set the 'swapiness' value to 0. This will prevent the system from swapping out process memory for disk cache.

      -molo

      --
      Using your sig line to advertise for friends is lame.
    4. Re:Try this with linux by Lumpy · · Score: 2, Interesting

      IMHO for a desktop system this makes no sense, that's why I run my 1GB RAM machines with zero swap.

      fine for you being a typical home user not doing much with your PC.

      now with me editing 4GB video clips, rendering a 2Gb CG clip or trying to process a large rotoscoping project in film-gimp 1GB of ram is consumed 3 minutes after I sit down at that machine.

      I have 2GB of ram + 4GB of swap and I can easily fill it all up using wither Blender, Film-Gimp or any of the other tools I use.

      and I'm betting that many others here that actually use their computers for real work instead of what they typical home user uses it for will also chime in.

      Basically, when you hit the top of your ram... hell will break loose on your machine... I can't afford to lose my work when I run out of ram, so I use swap to get more done.

      --
      Do not look at laser with remaining good eye.
    5. Re:Try this with linux by timeOday · · Score: 1

      Well you really don't know until you try. It's just as likely your machine would run faster with less disk access without swap. Just because the kernel chooses to use some swap doesn't mean bad things wouldn't happened with no swap.

    6. Re:Try this with linux by Anonymous Coward · · Score: 0

      Misconception:

      it is not necessarily _swapping_ things out. It may be evicting things from page cache instead. A better word to use instead of "swapping" is "paging", because it covers both kinds of behaviour. Swapping means writing to swap, and it's done for dirty page; the other kind of behaviour means kernel throwing away app pages it knows it can load again from existing files on disk.

    7. Re:Try this with linux by Jerf · · Score: 1

      + 4GB

      Here's a little test for you. Create a four gigabyte file on your hard drive.

      time dd if=/dev/zero of=somefile ibs=1K count=4M

      On my lil' laptop here, well, I gave up after the first gig, which took 8 minutes.

      Now, on your monstrous machine you could probably do better, but we're talking hard drives here, not CPUs; even if you have four disks RAIDed together for maximal 4x throughput (no redundency) that are each four times faster then my drive, the full 4 gig swap partition still takes a minimum of two entire minutes, and I wouldn't be surprised that you don't have quite that good of a setup (that's massive file-server quality).

      That is the fastest you could possibly fill up that amount of space in. In reality, it'll be a lot slower, because you never fill it up linearly.

      On a modern hard drive, I don't see how 4GB of swap could ever help anybody. If you have to routinely fill that space, you've already lost.

      I would be interested to find out how deeply into swap you're willing to still be using the computer. I would be very unsurprised, even with your ideal setup for swapping, if you ever go deeper then a gig. (And I'm being generous; my instincts are saying 256MB-512MB.)

    8. Re:Try this with linux by Anonymous Coward · · Score: 0
      Notice how sluggish the system is after doing something disk-intensive like watching a movie. That's because the kernel is caching as much of the movie as possible to memory and swapping your running apps out.

      And that's because the kernel doesn't have the IMHO-much-needed feature where there are limits on the percentage of physical RAM that will be devoted to caching a given single file. If you're trying to read a really big file, say 1GB, there's a very great chance that the cache will be mostly worthless anyway, because chances are you will read it sequentially. You have, say 512 MB of RAM available, so with no limits you will cache the first 512 MB as you read it. Then as you read the last 512 MB, the first 512 MB will be (slowly and painfully) flushed out of RAM to make room for the last 512 MB. Then if you try to read the file again (i.e. play the movie again), the last 512 MB will be cached, but that will be useless and you will have to re-read everything anyway.

      The point is, when the size of the file exceeds physical RAM or even (usually approximately) 1/2 of physical RAM, there is no point in trying to cache the whole thing, because you will never succeed. Most really large files are accessed purely sequentially anyway, so unless you can cache more than half the file, you will see absolutely NO benefit from caching and there will be much harm to other things that go swapped out to make room. Therefore, in 99.9% of the cases, you shouldn't even try to cache the entire contents of a really large file.

      Anyway, a certain other operating system I'm thinking of (not Linux, not Windows, not OS X) happens to do this kind of limiting, and it works out very well. There is essentially no negative effect, and the "I just burned a 600 MB CD from a .iso and now my computer has swapped out everything but the 600 MB file" phenomenon just does not even exist, because the kernel doesn't even try to cache the whole 600 MB.

  18. With the amount of RAM available by czephyr · · Score: 0

    Why are we whining about swap files any longer?

    IMHO, anyone running a system (WIN ME - XP) with less than 256MB RAM is nuts.

    I feel that if you want to remove swapping then have more memory than memory addresses. Let's see what happens when the machine has to figure out what to do with the extra memory it has.

    Back to topic: Really, how much is a GIG of RAM nowadays?

    I'm only just a l'il punch drunk :-)

    --
    Sincerely, Czephyr
  19. I just don't get it. by mcg1969 · · Score: 2, Interesting

    Seriously, I don't get it. How in the world can swap ever increase performance.

    Specifically, suppose I have one computer with 1GB of RAM and 1GB of swap, and another computer with 2GB of RAM and no swap. Under what circumstances will the first computer be any faster?

    Now I suppose if the swap is used for other things besides memory space then I could understand it. But then it seems like a simple solution would be to allocate a fraction of RAM for those things. In effect, create a swap partition on a RAM disk :)

    Seriously, I'd appreciate some education here, but make sure you answer my specific scenario above if you reply... thanks

    1. Re:I just don't get it. by multriha · · Score: 1

      Physical memory is always better than swap, nobody is claiming otherwise. A system with 1GB of RAM and a 1GB of swap should be faster than the same system withou swap.

      Should is the tricky part.

    2. Re:I just don't get it. by Anonymous Coward · · Score: 0

      I can't answer your scenario because your scenario is FLAWED. Of course having more ram will make the second system faster. There is no way the first could be faster. Thats not the issue. The valid comparison is a 1G machine with swap and a 1G machine without.

    3. Re:I just don't get it. by sprag · · Score: 5, Informative

      The potential speed increase isn't seen when comparing 1G RAM vs a 2G RAM system. Its comparing a 1G RAM system with a 1G RAM system with swap.

      The gist of it is: with swap you can put things that aren't being used (like mingetty, gdm, etc) into swap to free up space for things that are running now. Without swap you have to keep the little-used processes in memory and you don't have as much 'free' space to use for things like caches.

      Its also important to note that the kernel will swap out code segments regardless of whether or not you have a swap partition: they get swapped out to nowhere. When they need to be swapped back in, the executable file itself is read.

    4. Re:I just don't get it. by gerardrj · · Score: 1

      For the most part these people are wrong when they say that.
      There is no point where replacing disk swap with real RAM will slow things down in an average system, or conversely that using disk swap instead of RAM will speed things up.

      If you have 1GB RAM and 1GB swap, then change to 2GB RAM and 0GB swap, the OS will run faster. For one thing, there's a whole chunk of memory management code that doesn't need to run. Second you never have to wait for the relative eternity for data to get to/from disk.

      There is one possible exception that involves running mostly idle applications that get swapped out, and a one/ a few very active ones that do a lot of processing on a few files. In this case a swap enabled system could run some tasks faster. Assuming that the apps swapped out run only very infrequently, the space opened up in RAM would allow for more of the large files to be cached and hence accessed faster. But a significant portion of the data would need to fit in RAM, or you'll just wind up going to disk anyway and loosing the swap advantage.

      Personally, I don't use swap unless the system just physically can't handle the memory I need or I just can't get it installed at the moment. Once I know what the RAM requirements for the system will be, I configure enough to handle that and disable swap.

      One other thing: disabling swap may well let you spin down the hard drives more often, the system is (from my experience) much more tolerant of spin-up delay for accessing normal filesystems than swap.

      --
      Article X: The powers not delegated... by the Constitution...are reserved...to the people
    5. Re:I just don't get it. by Anonymous Coward · · Score: 0

      I think his point was that a computer with 2GB of RAM and no swap will be slower than a computer with 2GB of RAM and 1GB of swap. He says the swap can free up even more memory for cache, so if you're upgrading it makes sense not to disable it.

      I still bet that a computer with 2GB of RAM no swap will be aster than 1GB/1GB, unless I'm missing something very, very big.

    6. Re: I just don't get it. by Black+Parrot · · Score: 1


      > Specifically, suppose I have one computer with 1GB of RAM and 1GB of swap, and another computer with 2GB of RAM and no swap. Under what circumstances will the first computer be any faster?

      When the second one is still in its box at the computer store because you couldn't afford it.

      --
      Sheesh, evil *and* a jerk. -- Jade
    7. Re:I just don't get it. by hurterer · · Score: 1

      The thing is, with no swap file, you'll never get that 2-3 second pause when you're coming back to the computer after an hour or two.

      I think basically, I'm happy to buy the extra 512mb of ram because it means I dont get that momentary annoyance when I get back to my machine.
      I think that theres no need for a swap file (with win XP) if you've got 1GB+ ram.

    8. Re:I just don't get it. by mcg1969 · · Score: 1
      The potential speed increase isn't seen when comparing 1G RAM vs a 2G RAM system. Its comparing a 1G RAM system with a 1G RAM system with swap.

      OK, now this is what I thought. However, the original poster was asking the question, "why not just buy more RAM instead of using a swap partition?" and people seemed to be suggesting that it is always useful to have swap, no matter what. Hence my confusion. Thanks for the info.

    9. Re:I just don't get it. by mcg1969 · · Score: 1

      AC, when I read the article, I got the impression that the original poster was asking why it's ever worthwhile to have swap if it is feasible to just buy more RAM. Other people seemed to be suggesting that it was still worthwhile. That's why I posed the question the way I did.

    10. Re:I just don't get it. by neurojab · · Score: 1

      >Specifically, suppose I have one computer with 1GB of RAM and 1GB of swap, and another computer with 2GB of RAM and no swap.

      That isn't the issue at all. Buying more RAM will always improve performance. The issue is for a FIXED amount of ram, whether or not swap improves performance.

      I think the "issue" is quite silly anyway. 2GB of RAM with 2GB swap certainly ought to be at least as fast as 2GB of ram with no swap. If it isn't faster, or at least equal in performance, there's a tuning problem (see /proc/sys/vm/swappiness) or a bug in the VM subsystem.

  20. I'm curious how windows does it by Stevyn · · Score: 2, Interesting

    This may be slightly off topic...

    Running KDE 3.2.1 now, I notice it takes longer to open apps than it does in windows. Mozilla for example takes literally a few seconds longer to open each window than it did in windows. Another thing windows does is make it faster when you run an app right after you ran it then closed it. Say for example in windows I run mozilla, then close it, then open it. When it opens it the second time, it's almost instant. However in linux, it seems to take the same original amount of time to load it completely. I'm sure it has to do with an entirely different process of loading programs, but apps always seemed to open faster in windows than in linux, in my view.

    Then again, graphics used to be in the NT kernel and that's what made it appear fast, but lead to a lot of problems and crashes, so maybe the longer load time is worth the wait when compared to a reboot.

    1. Re:I'm curious how windows does it by g-to-the-o-to-the-g · · Score: 1

      Windows caches things. If you want the same sort of startup times as windows, look into something such as prelink.

    2. Re: I'm curious how windows does it by Black+Parrot · · Score: 4, Interesting
      This may be slightly off topic...

      Running KDE 3.2.1 now, I notice it takes longer to open apps than it does in windows. Mozilla for example takes literally a few seconds longer to open each window than it did in windows. Another thing windows does is make it faster when you run an app right after you ran it then closed it. Say for example in windows I run mozilla, then close it, then open it. When it opens it the second time, it's almost instant. However in linux, it seems to take the same original amount of time to load it completely. I'm sure it has to do with an entirely different process of loading programs, but apps always seemed to open faster in windows than in linux, in my view.

      Then again, graphics used to be in the NT kernel and that's what made it appear fast, but lead to a lot of problems and crashes, so maybe the longer load time is worth the wait when compared to a reboot.
      Conventional wisdom is that Windows uses lots of hacks to make it "look" faster in the way you describe, without regard to the cost it imposes on other operations. I'm almost certain that XP keeps some applications in memory after you "exit" them. Sometimes I notice that something won't work after running certain big applications, suggesting that sufficient resources haven't been released. Also, sometimes a shutdown complains about an application that won't respond even after you've closed everything. I think they're hoaxoring people to think they got a fast system, when they're really just robbing Peter to pay Paul.

      --
      Sheesh, evil *and* a jerk. -- Jade
    3. Re:I'm curious how windows does it by iocon · · Score: 1
      Windows keeps dll's in memory after use for 'a while'. You can prevent this to help quickly free memory for swap and other apps by changing a registry setting:
      [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Cur rentVersion\Explorer]
      "AlwaysUnloadDLL"="1"
      There are other tweaks too, like not paging out any kernel code or keeping multiple copies of dll's for stabilty. Gotta have 1GB for most of them to be helpful though.
    4. Re: I'm curious how windows does it by Anonymous Coward · · Score: 0

      Summary: Windows is faster than Linux so it must be cheating and not just better programming.

    5. Re: I'm curious how windows does it by Kaenneth · · Score: 1

      This is true.

      The 'Start' Menu for example, is often cached as a non-functional bitmap, then invisibly redrawn after Windows builds the structures needed to make it function (mouse over/click bounderies, tooltips, fly-outs, etc.)

    6. Re:I'm curious how windows does it by dabraun · · Score: 2, Interesting

      One of the things that makes XP start apps very quickly is this:

      It watches applications startup and monitors what they read from the disk - it notes this in a log. During idle time it moves the sectors around on disk so that they will all be in the same place for the next time you start that app. When you start the app later it runs out and reads everything that it believes the app will want to read all at once. This pre-reading and disk order optimization makes XP start apps a heck of a lot quicker than previous versions of the OS did.

      It also does exactly the same thing for the boot process. There's even a tool you can download from MS's web site that will allow you to force the system to clear what it thinks about the boot process, reboot, and force the ordering to take place immediately rather than during idle time.

      David

    7. Re:I'm curious how windows does it by rikkus-x · · Score: 1

      Did you try prelink?

      Install prelink, configure it via /etc/prelink.conf so that it covers the directories where KDE lives, then run it. KDE apps should start much, much quicker.

      I don't think this has anything to do with swap, because if you open an app, close it, then open it again, it should be in RAM cache, so any startup time is down to:

      1. Run-time linking - which takes ages for C++ apps without prelink, due to the huge number of symbols.
      2. The app doing its own initialisation.

      I think prelink should help for Mozilla too, as it's written mostly in C++ AFAIK.

      Rik

    8. Re:I'm curious how windows does it by spitzak · · Score: 1

      Linux will certainly run the same application (or another application using the same shared libraries) much faster the second time. This effect is obvious if your application is over NFS.

      I would blame most of the slowness in GUI applications on X, which is not fast no matter what people claim. Try command-line things such as running a script that calls a lot of programs like compilers under tcsh on both systems and it is obvious that Linux exec's non-GUI programs many times faster.

    9. Re: I'm curious how windows does it by omicronish · · Score: 1

      Also, sometimes a shutdown complains about an application that won't respond even after you've closed everything. I think they're hoaxoring people to think they got a fast system, when they're really just robbing Peter to pay Paul.

      In all cases I've seen this has been a result of hidden programs or bad programs that spawn other hidden programs that aren't closing properly. As an example, a Logitech MouseWare helper program sometimes refuses to die upon shutdown. Remember that there can exist non-visible programs, so what you see on the taskbar is not representative of all the programs you are running. Try the Task Manager for that (Ctrl+Shift+Esc).

      With regards to the resource problem, it's entirely possible Windows has initialized or allocated some resource at the request of a program and hasn't released it. You can think of it as delayed initialization to speed up startup. As an example, instead of initializing the web browser control when you first log on, it can be initialized when it's first used instead.

    10. Re:I'm curious how windows does it by omicronish · · Score: 1

      Then again, graphics used to be in the NT kernel and that's what made it appear fast, but lead to a lot of problems and crashes, so maybe the longer load time is worth the wait when compared to a reboot.

      AFAIK, the graphics subsystem has been moved to the kernel to improve performance. One consequence of this, at least on older versions of Windows (2K or NT4, perhaps), is that a bad font can crash Windows.

  21. gmail by maxbang · · Score: 3, Funny

    I use my gmail account as my swap partition. It's fully searchable and displays helpful advertisements every time I load fifty tabs in Firefox and OpenOffice goes idle. I don't know what I'd do without it. I'd probably be less of an unfunny jackass.

    --
    I also reply below your current threshold.
    1. Re:gmail by djplurvert · · Score: 1

      Every time I read "g"mail, I read it as "gay"mail...I'm not saying that means anything or anything, just something I observerd.

    2. Re:gmail by maxbang · · Score: 2, Funny

      Dude, that's the funniest thing I've read today. And I'd totally date you, but my IQ is four. I'm typing this with a toothbrush that's stapled to my head.

      --
      I also reply below your current threshold.
    3. Re:gmail by Geoffreyerffoeg · · Score: 1

      Speaking of using the Internet as swap....

      Could you use packets continually circulated around the Internet as literal "swap"? Make a large number of small packets distributed via different paths, so each router only holds a couple kB or so. Make routing tables that say those packet (addressed to 127.0.0.254 or something else dumb) is to be circulated continually, and when you need it again update the routing tables to route it "through" (to) your own computer.

      It would take no space from your drive, and it's theoretically infinite (has the whole Internet ever run out of memory before?).

  22. okay, here's a challenge... by Doppler00 · · Score: 4, Insightful

    Does anyone out there want to run a series of benchmarks with a few standard applications to prove/disprove whether disabling swapping improves performance?

    I'm tired of just hearing antidotal evidence on this. Everyone has their stories about turning off swap files and improving performance, but in what cases? Are there some users this would harm?

    1. Re:okay, here's a challenge... by thebatlab · · Score: 1

      I'm even tired of hearing anecdotal evidence

    2. Re:okay, here's a challenge... by Doppler00 · · Score: 1

      okay, I made a typo and I'm tired.

    3. Re:okay, here's a challenge... by Trepalium · · Score: 2, Insightful

      I think it's simply a case of, 'there's no simple answer'. Even a benchmark would be difficult to do, because it would vary depending on workload. You might be able to handle a particular machine with no swap, but I would find it unusable. I'm not even sure how you would test this. What kind of performance would you test? Latency? I/O throughput? Integer instructions per second? If you turned off cache, your maximum latency and insn per second might increase, but your throughput may decrease.

      --
      I used up all my sick days, so I'm calling in dead.
    4. Re:okay, here's a challenge... by arvindn · · Score: 2, Insightful
      Unfortunately, that's very difficult, perhaps impossible.

      The users who are complaining about swap are saying that it decreases desktop responsiveness. Responsiveness is different from performance, and is frequently antithetical to it. It is inherently subjective and therefore hard to quantify.

    5. Re:okay, here's a challenge... by geekee · · Score: 1

      The purpose of disk caching is to give your system more memory than it actually has in RAM. It doesn't improve performance, but instead allows you to run jobs that require more memory than your computer has. In fact, if your job needs to work on large chunks of data at a time that are larger than can fit in main memory, your machine will start thrashing, that is, spend most of its time moving data to and from the disk, and very little time computing anything.

      --
      Vote for Pedro
    6. Re:okay, here's a challenge... by Anonymous Coward · · Score: 0

      You're confusing caching with virutal memory. Caching uses real, fast RAM to store/pre-read/re-use data instead of reading it from a slow disk every time.

    7. Re:okay, here's a challenge... by maxwell+demon · · Score: 1

      Now, IIRC the scheduler had exactly the same problem, and it was solved by distinguishing interactive and noninteractive processes.

      Now since that info is already available in the kernel, why not use it as well for swapping? Say, noninteractive processes may be swapped out in favour of file cache, and interactive ones may not, and when in doubt, prefer swapping out noninteractive processes versus interactive ones.

      This would then also automatically scale for different usages: Server I guess will have very few interactive processes (probably mainly a few shells, for which good responsibility is good even on servers, f.ex. to be able to quickly kill processes going wild), and therefore few processes will be affected. OTOH on workstations, interactive processes are quite common and with this scheme will not be thrown out e.g. by an updatedb started through cron.

      --
      The Tao of math: The numbers you can count are not the real numbers.
    8. Re:okay, here's a challenge... by Anonymous Coward · · Score: 0

      No, a typo is when you know the correct spelling and accidentally mistype it. It is hard to accept that you knew the correct spelling when you screw up an entire syllable.

    9. Re:okay, here's a challenge... by IHateUniqueNicks · · Score: 1

      http://forums.newsbin.com/viewtopic.php?t=7645
      Yo u will find HUGE numbers of people in that forum who HATE the fact that WinXP needlessly swaps out 100s of Mb of data, and takes minutes to read it back in when needed.

      In this case, disabling swapping hugely improves performance. But then, it's less MS code running, and that always helps. :)

    10. Re:okay, here's a challenge... by jazman · · Score: 1

      I'm not sure how you define "standard applications" and how to differentiate between a scientific test and anecdotal evidence, but here's the result of my experiment.

      PC: 512MB RAM, 700MB swap, WinXP. PC is on most of the time. Software running, primarily Shareaza, Firefox, Thunderbird and.......GRISoft AVG.

      I reckon GriSoft AVG triggers the problem - when it does its nightly virus check, scanning the entire hard drive, everything gets swapped out to HD. So when I start clicking on FF/TB, they seem to have to load everything back in from swap, which seems to be considerably slower than reloading the application from the executable - we're talking of OVER THIRTY SECONDS response every time I click on something, until I click on the same thing the second time then it's ok. In fact, sometimes it's quicker to turn off the PC and wait for it to reboot than to try clicking stuff. (turn off: sic, because Shart - Shutdown seems to have been hidden somewhere in swap and can't be found)

      Last night after reading this thread I reduced swap to 50MB. This morning, started clicking on FF/TB - response: normal. No 30 second wait for tab clicks, Ctrl-T etc. Big improvement.

    11. Re:okay, here's a challenge... by jazman · · Score: 1

      You're probably right, but I couldn't find those huge numbers - dug around for a while but I don't know what subject they're posting under. Your URL refers to a single post that has nothing to do with swapping. Do you have a more relevant URL?

    12. Re:okay, here's a challenge... by IHateUniqueNicks · · Score: 1

      Sorry, you're right, the FAQ doesn't mention that Windows will needlessly swap it out while "idle", I thought it did.

      Here's a real example:
      http://forums.newsbin.com/viewtopic.php? t=8859

      Searching for freeze or lock will return dozens more.

  23. Swapless even with 1GB of ram by Piranhaa · · Score: 0

    I remember when I had disabled swap completely under windows XP. The first program that gave me annoying errors was photoshop. Every time it would start up it would say "Photoshop detects there is no swap, and it should be used or problems can occur with your system". (something like that). Also, some games (empire earth for one) would not even run without a swap partition. So even though you don't technically NEED one, some programs still rely on it!

  24. Hardly ever use swap by yhetti · · Score: 1, Offtopic

    None of my machines have less that 512 megs of RAM, (or more than 1.8GB) and I never use swap...never have a problem with it. It's faster because drive access doesn't have to compete w/ swap (even on SATA it's annoying).

    Okay...I lied. Does anybody else use Pan? I mean..wtf?! When I run Pan it's more like

    $ cat /dev/zero > /swap.tmp
    *wait 20 seconds*
    $ mkswap /swap.tmp
    $ swapon /swap.tmp
    $ exit
    # pan

    Pan is an awesome program, but seriously...when it can single handedly use > 1GB of RAM just stealing divx rips...

    1. Re: Hardly ever use swap by Black+Parrot · · Score: 5, Funny


      > Pan is an awesome program, but seriously...when it can single handedly use > 1GB of RAM just stealing divx rips...

      Think of it as a sin tax.

      --
      Sheesh, evil *and* a jerk. -- Jade
    2. Re: Hardly ever use swap by yhetti · · Score: 1

      Good call!

      I got mod'd down : ( I thought I was on topic....but then again, it really was just more anecdotal evidence.

  25. We don't need swap by Anonymous Coward · · Score: 1, Funny

    We can just make an OS that reboots every time it runs out of memory. Oh, wait, someone already did that...

  26. What about Diskless Drives! by Anonymous Coward · · Score: 0

    Alot of companies around here have started purchasing diskless drives for their workplace. SWAP is pretty darn useless then.

    If you need to use Swap for what your doing with your computer, then you obviously don't have enough ram!

    1. Re:What about Diskless Drives! by shione · · Score: 2, Funny

      Did anyone else read that as dickless drives? Man I think I need glasses.

  27. well one reason by discogravy · · Score: 2, Informative

    one reason you'd want swap on a system is to have someplace to dump/savecore information in the case of system crashes. Kind of hard to do with volatile memory.

    1. Re:well one reason by Anonymous Coward · · Score: 0

      Sorry to spoil your perferct world, but if your system crashes, you don't have the time to dump RAM to disk. And given that what's in the swap partition doesn't make much sense without the other half that's in RAM, and the tables that describe how it all fits together, the contents of a swapfile after a crash aren't terribly useful.

    2. Re:well one reason by BCoates · · Score: 1

      I don't know how linux crashes, but NT can be configured to dump its entire RAM onto a preallocated portion of the drive when a blue-screen bugcheck happens. It worked for me almost 100% of the time (on a system with some very marginal hardware; grepping through the resulting mass of raw memory was annoying, but not as much as losing the documents I was working on)

      There isn't really a time limit for how much your system can do after a system crash, the problem is that you can't trust your kernel data, the state of your hardware devices, etc., so there's not much useful work you can do in that state

  28. It's a choice... by Beolach · · Score: 4, Interesting

    As I RTFA & previous comments here, I was rather suprised at how argumentive people were getting over this. Some people are saying swap is an absolute necessity & a swapless system was a broken system, while other's said swap was an obsolete solution to a problem that no longer exists (expensive RAM). This seems odd to me, because as far as I can tell, the decision of whether & how much swap to use is based mostly on two things: specific situations (and thus there is no general answer to 'Is Swap Necessary?'), and opinion. And either way, with the Linux kernel today (and for quite a while now), I can choose for myself whether or not, and how much, swap I want to use. So if I am in a situation that I think requires swap, I can use it, and in a situation that I think would be hurt by having swap, I don't have to use it. So I don't see why there's so much hoolabaloo about this: nobody is forcing anyone to do it one way or the other. And if someone else thinks it should be done different from how I would do it, that's their decision, not mine.

    --
    Join moola.com, play games to earn money.
    1. Re:It's a choice... by Anonymous Coward · · Score: 0

      The root of the argumentiveness is that people aren't clear on the difference between "Paging" and "Swapping" -- they use the terms interchangably, but they aren't the same thing.

      Roughly:
      Swapping is running out of memory and removing active segments from RAM. This is "bad".

      Paging is removing inactive segments from memory so that the memory can be used for a higher purpose. This is "good".

      Of course, sometimes the system gets it wrong and pages when it shouldn't, and that only further confuses the issue.

    2. Re:It's a choice... by dustmite · · Score: 1

      Paging is removing inactive segments from memory so that the memory can be used for a higher purpose. This is "good".

      But that's the point, it's not necessarily good. If, say, some rich guy buys a PC with 2GB RAM just to do a little web browsing and e-mail, and never even uses more than a couple hundred megs RAM, then any sort of paging/swapping to disk is only going to unnecessarily slow down the system. You can load everything you need in RAM, and keep it there (writes notwithstanding of course). We had a specific application we developed, running on Win2K, that we knew only needed about 380MB RAM, and we bought systems with 512 MB RAM, more than enough to hold EVERYTHING we needed and this was the only application that would run on the system. Yet Windows would "pre-emptively" start swapping as much as possible to disk after the first 256 MB had been allocated, hurting the application's performance noticably and unnecessarily (real-time terrain database visualization).

    3. Re:It's a choice... by Anonymous Coward · · Score: 0

      You're talking about 2 different scenarios. Paging won't slow down the "rich guy's" system -- he doesn't want crap like startup code in memory, he'd rather have a disk cache. I have 1GB, and I don't notice any slowdown from paging. (although I suppose there's some idiots with tons of RAM and a really crappy disk subsystem..)

      In your case, Windows wasn't "swapping", it was "paging" stuff it incorrectly thought was unused to disk. This seems like something that could be programmed around, but I don't know enough about win32 to say exactly. There's nothing wrong with the idea -- it's the implementation that wasn't working for you.

  29. Run Pan by Anonymous Coward · · Score: 0

    load a binary newsgroup of 500K+ posts (on my system)
    watch performance drop to zero.

    or load one with 750K+ posts and watch you run out of memory. dmesg errors (process killed out of memory)

    thats when swap and RAM were filled

  30. swap deals with bloat by wotevah · · Score: 4, Insightful

    Most applications today have unnecessary or rarely used portions of code or data - bloat. These get swapped out first. Also there are various memory leaks here and there, which means the programs sometimes forget to release allocated memory they do not need any longer.

    Look at the size of your X server, or mozilla, or apache, or pretty much anything else and you will see over the course of a few weeks that it has grown beyond reasonable operation demands.

    The memory lost this way is never accessed from there on, but the system cannot release it without the program telling it to, so it does the next best thing and shoves it in the swap. Not a solution since eventually swap gets full, but since the leaks are slow to begin with, at least it prevents them from affecting system performance too early.

    1. Re:swap deals with bloat by Skapare · · Score: 1

      So why try to fix the symptom (heavy swapping). Instead, fix the cause (bloat). Let's go back to efficient programming that only 5% of C programmers know how to do (using lean code and scalable algorithms).

      --
      now we need to go OSS in diesel cars
    2. Re:swap deals with bloat by spitzak · · Score: 2, Interesting

      Unfortunatley that bloat is also *fragmented*. Even a 4-byte structure that is still in use buried in a page will keep it swapped in. In my experience the only way app pages get swapped out is when the app is idle.

    3. Re:swap deals with bloat by BZ · · Score: 1

      > The memory lost this way is never accessed from
      > there on, but the system cannot release it
      > without the program telling it to,

      It's worse. If it's allocated on the C heap and there's something allocated past it, the system can't release it even if the program DOES tell it to. Yay lack of heap-compression in C.

  31. The Kernel Can Take a Hint by EventHorizon · · Score: 5, Informative

    In the average case code and data _do_ tend to be accessed more than once. We would all be complaining a lot more if the kernel NEVER cached... remember the huge performance boost SMARTDRV made in DOS?

    So, frankly, the default kernel behavior is right.

    To fix the movie/updatedb/jumbo cp/etc issues see "man madvise" and check out MADV_DONTNEED. I am hoping applications will start using this syscall sooner, rather than later. The Linux VM can take a hint, and it's pretty easy to give it one.

    1. Re:The Kernel Can Take a Hint by entrigant · · Score: 1

      I don't quite see how this will help with keeping larger files such as movies from filling up the disk cache when being played. This syscall is about memory, not about the disk cache. Is there a syscall to tell the kernel that the application won't be accessing a part of the disk more than once?

    2. Re:The Kernel Can Take a Hint by Spy+Hunter · · Score: 0, Troll

      Requiring extra linux-specific code just to get decent performance is dumb. Sounds to me like the kernel needs a simple profiler to assess the way files are being accessed. Large file + sequential access = read-ahead w/ small cache; large file + random access = large cache w/ recent pieces; small files + repeated access = large cache holding complete files; etc. Would this not solve the problem for everyone?

      --
      main(c,r){for(r=32;r;) printf(++c>31?c=!r--,"\n":c<r?" ":~c&r?" `":" #");}
    3. Re:The Kernel Can Take a Hint by ndogg · · Score: 2, Informative

      linux-specific code
      Linux-specific code? Did you bother to look at the man page? Didn't think so...

      And I quoth from my man page:CONFORMING TO
      POSIX.1b (POSIX.4). POSIX 1003.1-2001 describes posix_madvise with constants POSIX_MADV_NORMAL, etc., with a behaviour close to that
      described here. There is a similar posix_fadvise for file access.

      --
      // file: mice.h
      #include "frickin_lasers.h"
    4. Re:The Kernel Can Take a Hint by cerberusss · · Score: 1
      check out MADV_DONTNEED. I am hoping applications will start using this syscall sooner, rather than later

      Actually, this should also be a command-line utility. That way, it'll be available for all applications.

      --
      8 of 13 people found this answer helpful. Did you?
    5. Re:The Kernel Can Take a Hint by swilver · · Score: 3, Insightful
      The default kernel behaviour is WRONG. The whole idea of memory is to put in stuff that will be likely to be accessed again. How likely is it that you will be watching a 1 GB movie again?

      Of course, the Kernel will have no idea about watching movies, but it stil can distinguish this "unimportant" data from data that do needs to be cached. The most important way to distinguish this data from data that does need caching is how fast it is needed in the first place.

      When I do a grep on the kernel tree, you'll find that your harddisk speed is bottle neck; it is worth caching this data as grepping from memory would enhance its performance.

      When I play a movie, the harddisk is not the bottleneck, in fact, NOTHING is a bottle neck, as my movie would be stuttering and unwatchable otherwise. This data is not worth caching (atleast not worth caching so much of it to the point of swapping out all else).

      This goes for most media streams, but also for interaction with the internet (downloads/uploads/p2p). There's no need to keep a 1 GB file cached when that file has "accumulated" cache space in the course of an hour or more (ie, slow I/O); if it was important enough to warrant caching, I'd think the harddisk would have been the bottleneck in the first place...

      --Swilver

    6. Re:The Kernel Can Take a Hint by legrimpeur · · Score: 1

      Well since in most cases programmers do not use madvise a solution colud be the "autoregulate swappines" patch by Con Kolivas.

    7. Re:The Kernel Can Take a Hint by 0123456 · · Score: 1

      "In the average case code and data _do_ tend to be accessed more than once."

      The vast majority of data I access on my PC will not need to be accessed again for minutes, if that, or is in files so large that they're impossible to cache. And the vast majority of files are either small text files (e.g. cached web pages) which can be loaded in a split second or huge video files which the video editing application can cache far more efficiently than the kernel can.

      "So, frankly, the default kernel behavior is right."

      I'm not sure about Linux, since I haven't reinstalled it after loading XP onto this machine, but it sounds like it's now doing precisely the same braindead things that XP loves to do. Only a moron would swap out running applications to try to cache a 2GB file when I'm copying it from one drive to another, and that's precisely what XP does.

      The simple fact is that the time taken to swap in Mozilla when a braindead operating system has swapped it out to disk in order to cache another 100MB of a file I'm not going to access again for hours, if that, is huge, while the time saved by having a huge disk cache is tiny. I really don't understand why kernel developers (XP or Linux) can't see this.

    8. Re:The Kernel Can Take a Hint by glitchvern · · Score: 1

      The syscall is about letting the kernel know that the memory being filled from a file (mmap'ed I am guessing) will be accessed only once sequentialy, so that it does not swap out other more important parts of memory to load up an entire media file into ram. It is about not sending things to the swap on disk. It has nothing to do with the disk cache. posix_fadvise is the equivalent syscall for files, but the man page does not say that it makes the optimazation you are looking for (although it may, I do not really know).

    9. Re:The Kernel Can Take a Hint by Foolhardy · · Score: 2, Informative

      Don't blame XP's kernel. When you open a file in Windows that you plan on reading sequentially, you're supposed to use FILE_FLAG_SEQUENTIAL_SCAN. This is a big hint that you won't be seeking randomly or backwards, so only a little read-head caching should occur. By default, the cache manager thinks you will want to access the file randomly, so it stores as much as it can for your convenience. It is the program copying the file (probably explorer in this case) for not providing that hint.

      Actually, copying a file shouldn't be buffered at all; it should use an IO completion port and multiple (mabye 10) concurrent async IO operations to copy the file witn no buffering.

    10. Re:The Kernel Can Take a Hint by DunbarTheInept · · Score: 1

      The difference is that SMARTDRV didn't have the ability to degrade the performance of running programs by swapping their pages out. It only used memory that the apllication doesn't. The linux VM can go way overboard and use up too much of the ram for disk cache and not enough of it for programs. In my opinion (and granted, I'm not a kernel expert by any means), the VM should 'score' the use of a memory page for disk cache less than it scores the use of a memory page for program execution. So if two pages have both been used about 1 minute ago, but one was used for disk cache and one was used for program execution or data, then the disk cache page should be a candidate for swapping out first. The score shouldn't be based ONLY on the time since the last access. The score should take into account that a programmer writes a program *expecting* disk access to be slow and expecting RAM access to be fast. If the VM is making this not be the case, then the VM is doing something wrong.

      --

      Don't label something "offtopic" unless you know the topic well enough to tell what's on topic.

    11. Re:The Kernel Can Take a Hint by DunbarTheInept · · Score: 1

      It should be a globally settable thing by the admin, at runtime, but not something you have to set on a per-application, per-run basis - that gets tedious and most people won't bother, just like they don't bother with ulimits for the same reason. The admin should be able to say, "Since I want to use this machine as a file server, I'll set up the VM to score disk access high in the paging scheme. But that other computer over there is a workstation, so I'll set it up to score disk caching low in the paging scheme."

      Basically, the decision on which page to evict from memory should be based on BOTH how long ago it was used, AND what it was used for, and which way to favor one over the other should be settable at runtime, not just compile time. (i.e. This is a file server so I will have the VM score disk cache pages the same way it scores program pages, giving them equal weight, but that machine over there is a workstation, so I will have it's VM score disk cache pages as "quadruple decay time" pages - meaning a disk cache gets "old" faster and is swapped out four times faster than a program's page would be.

      --

      Don't label something "offtopic" unless you know the topic well enough to tell what's on topic.

    12. Re:The Kernel Can Take a Hint by DunbarTheInept · · Score: 1

      Shouldn't the VM part of the kernel be able to "learn" the pattern of access to a file on the fly? Imagine if for each file there was a simple number stored in the kernel that remembers "this was the previous block that was loaded from the disk for this file", and another simple integer that represents "sequentialness". It starts at zero. Each time a new block has to be swapped in for that file, it notices if it is sequentially adjacent to the previous block (either forward or backward). If so, it increments the "sequentialness" counter by one. If not it decrements it by one. This counter then becomes a heuristic for how sequential the access to that file is. If it's a large positive number, then that means that that file has tended to be accessed in a very sequential fashion. If it's a large negative number, then that means that file has been accessed in a very random fashion.

      This number could then be used to change the score when the VM's deciding which page to swap from memory. A disk block for a highly sequentially accessed file should be swapped out even if it's not that old yet - it should become a candidate much sooner than a page for a random-access file or a page for program code or program data.

      That would solve the "watching a long movie file" problem, without the programmer having to do anything special. The cached disk blocks for a long movie file would end up with a very high "sequentialness" score, and thus be swapped out quickly.

      --

      Don't label something "offtopic" unless you know the topic well enough to tell what's on topic.

    13. Re:The Kernel Can Take a Hint by cerberusss · · Score: 1
      It should be a globally settable thing by the admin, at runtime, but not something you have to set on a per-application, per-run basis - that gets tedious

      Well, most user couldn't be bothered but the creator of a distribution will probably be interested. I'd imagine it could be some sort of wrapper, just like rlwrap, (providing readline capabilities to any program by passing the program as a parameter to rlwrap).

      --
      8 of 13 people found this answer helpful. Did you?
    14. Re:The Kernel Can Take a Hint by DunbarTheInept · · Score: 1

      Despite the brainwashing of the public that Microsoft did back in the days of their NT server and workstation distributions, you shouldn't have to buy an entirely different distribution of the OS just to change a few parameter settings.

      It should be something you can change in the sysconfig, just like how many locks there are, or any of the other similar settings that are related to server versus workstation tweaking.

      --

      Don't label something "offtopic" unless you know the topic well enough to tell what's on topic.

    15. Re:The Kernel Can Take a Hint by cerberusss · · Score: 1
      [...] you shouldn't have to buy an entirely different distribution of the OS just to change a few parameter settings

      For me, that's just too broad. I want Mozilla to never get swapped out, but I don't care about sshd or other daemons that I've got running, but don't use interactively all the time. A big switch is not enough for me. For others, it might be enough.

      --
      8 of 13 people found this answer helpful. Did you?
    16. Re:The Kernel Can Take a Hint by terriblecertainty · · Score: 1

      Sequential file access detection could probably be done, if not in the general case, then in a large number of cases.

      However, I think a better solution is to add code to those userland applications to use the already available mmap()/madvise() (MADV_SEQUENTIAL or MADV_DONTNEED, as mentioned before) or even open() w/ DIRECT_IO (bleh), and assume the kernel will do the right thing. The applications are in a better position to make this determination than the kernel.

      I've actually had to fight the perception that swap causes bad behavior on every unix variant I've administrated. Once in awhile, people do notice some bad behaviors, but most of the time, the system will just adapt to the new workload, given time.

      I'm not sure why this is even a thread. If you don't like swap on your desktop machine, turn it off (or down), in one of the several methods available. I'm keeping mine.

    17. Re:The Kernel Can Take a Hint by DunbarTheInept · · Score: 1

      The problem with asking applications to fix a problem is that this only works on new applications.
      I want a solution that works regardless of whether or not the programmer thought of using it. That way it works retroactively on the whole pile of already-written unix tools.

      --

      Don't label something "offtopic" unless you know the topic well enough to tell what's on topic.

  32. Eventually... by aphor · · Score: 1

    Eventually my persistent storage device will be solid state with ultra-efficient DRAM and integrated batteries, and my system RAM will be a big SRAM space. I will want to swap to DRAM.

    --
    --- Nothing clever here: move along now...
  33. Uninformed opinions by Anonymous Coward · · Score: 1, Informative

    I for one want to avoid MBR screwups and the hassle of communicating with NTFS, so I don't dual boot.

    The fact that you irrationally avoid two very mature and easy-to-understand technologies implies you are uninformed and compels me to ignore any suggestions you might have.

    I've heard that Unreal-engine based games in particular make heavy use of swap filing.

    "You've heard"? As in, someone told you to believe it but you didn't take the time to think about the claim yourself? No application can "make heavy use of swap filing". Either it uses a lot of RAM or it doesn't. And either it accesses RAM in a predictable pattern (condusive but to swapping) or not. But an application can't actually make use of swap filing: it always -thinks- it's using RAM. The OS will always decide whether it's time to swap in or out.

    1. Re:Uninformed opinions by Anonymous Coward · · Score: 1, Informative

      Some parts true.

      A application can request unswappable and swappable memory. Sure, it can't say "store me in swap", it can, however, allocate as much RAM as it can.

      UT2004 does use LOTS of RAM. 512MB is far from enough with high detail settings and preloading of textures etc. SWAP with a 512MB system is a nesessity for UT2004

    2. Re:Uninformed opinions by Carewolf · · Score: 1

      The fact that you irrationally avoid two very mature and easy-to-understand technologies implies you are uninformed and compels me to ignore any suggestions you might have.

      And you sound like a troll.
      It has nothing to do with the maturity of the technology, but Microsofts lack of will (reason) to cooperate. It is annoying you can't write to NTFS from Linux, because it has to be a secret, and it is very annoying that Windows automatically removes linux-booters every time it is reinstalled (and tries to fool the user to think that linux partitions are free space (not even corrupted, but free!)).

    3. Re:Uninformed opinions by shish · · Score: 1

      An app can make it's own swap file and use that - eg you can set a RAM limit on the GIMP, and once you go over that limit, images that you've opened but not touched for a while end up in files like ~/tmp/gimp-12345.xcf. It's more autosave/autoload than swap in the OS sense, but it has the same effect.

      --
      I mod down anyone who says "I will be modded down for this", regardless of the rest of their comment
  34. Amiga by Jace+of+Fuse! · · Score: 4, Interesting

    In the 90's, I ran a 10 line BBS on an Amiga 4000 with 16 megs of Fast ram, 2 megs of Chip ram, and 0k for the swap file. :)

    I know, I know, the Amiga didn't HAVE virtual memory. Well actually it did if you had an 040 and installed a memory management program such as GigaMem, but so few people had a use for such a thing that it was practically unheard of.

    Oh, and before someone jumps in saying that I wasn't able to do anything else, that is totally NOT the case.

    Very often I was doing lots of stuff. The difference is developers were used to working within memory constraints, and now days developers are used to systems growing into the applications.

    --

    "Everything you know is wrong. (And stupid.)"

    Moderation Totals: Wrong=2, Stupid=3, Total=5.
  35. IYHO by nfabl · · Score: 1

    From what i gather one of the reasons swap is considered necessary is that its not possible to shift pages around in physical memory to optimize things.

    (Note: this is me speaking out of my arse, please correct me flamefree :P)

    Say you have 100 meg of ram (to make things easier) and 5 applications have 10 meg of ram allocated to them at equally distant addresses. Application #1 says it needs 60 meg allocated sequentially. In order to do that 60 megs, a couple of other apps will need to be swapped out.

    Now, without swap that wouldn't be possible, so the allocation would fail.

    So what interests me is if you had a RAM disk set as swap would that make this possible, and the whole swap thing more efficient? Say 1/4 ram is ram-swap, and have another 512meg as disk swap at a lower priority?

    1. Re:IYHO by rd4tech · · Score: 1

      Say you have 100 MB ram and 200 MB swap and your application need 301 MB to load. It's simple, you don't have enough juice to run it. But on the other hand, I like the idea of using some of the drive, at an extremely low priority, for 'just in case'.

    2. Re:IYHO by rabidcow · · Score: 1

      From what i gather one of the reasons swap is considered necessary is that its not possible to shift pages around in physical memory to optimize things.

      Paging takes care of that. Even if you only had one address space, any virtual address can be mapped to any physical address. (with a resolution of some page size)

      But applications often allocate more memory than they're actually using at one time. Eg, open a second tab in Mozilla and ignore the first for a while. It has to keep all the data for that allocated, but it's just sitting there. Without swap, you might have to close tabs and reload the data later instead of keeping it up for reference.

    3. Re:IYHO by Nutria · · Score: 0

      Even if you only had one address space, any virtual address can be mapped to any physical address. (with a resolution of some page size)

      Specifically, you have one physical address space, and the CPU's MMU makes it so that every process' virtual base address is 0.

      --
      "I don't know, therefore Aliens" Wafflebox1
    4. Re:IYHO by rabidcow · · Score: 1

      Even if you only had one address space

      Sorry, this is unclear. I meant "one virtual address space". You almost never have only one virtual address space, but if you did you'd still have ample space to remap 100MB.

      Specifically, you have one physical address space,

      Usually, as far as we are concerned at the moment.

      and the CPU's MMU makes it so that every process' virtual base address is 0.

      I'm not completely sure what you're trying to say, but on some architectures that is both wrong and irrelevant. On x86, you usually have all of the segment bases set to 0, but that has nothing to do with paging.

  36. Rule of Thumb: 256MB on x86 by Anonymous Coward · · Score: 0

    when a board has more than 265MB RAM, swap may be well suited for 3 things.

    1. Java
    2. Python
    3. Earwax

    All 3 in common; when unchecked, they fall down at most inappropriate time.


    =================
    Q: What's your name?
    A: Slim
    Q: Slim Shady?
    A: No, Slim Jim
    Q: A Beef Jerky?
    A: No, I'm just black on the outside and light in the inside.

  37. I have never... by Anonymous Coward · · Score: 0

    ... seen any swap usage, at all, on my Linux box... OK, granted I have a gig of ram. But I do like to use xmms, kde 3.2, mozilla, and other memory hogs. I guess what I'm saying is that for people like me, swap is pretty much necessary, because not everyone has a gig of ram.

    Now, I would like to see Windows manage the above scenario... I had Win2k on the same hardware and it never used more than around 650 MB of the physical RAM, and still swapped around 200MB when I was using stuff that wanted huge amounts of ram (photoshop, etc)

  38. U R N Idiot by Graymalkin · · Score: 4, Informative

    I haven't seen a case where disabling swap actually increases performance. I have however seen lots of cases where disregard for logic involving swap space caused serious performance problems. The old 1.5x and 2x rules for swap space are outdated and even dangerous in today's systems with ooglebytes of memory.

    With less than 128MB of RAM you practically need 2x your physical memory worth of swap space. Running a full GUI environment, even a relatively lightweight one, needs quite a bit of system memory. With 64MB of RAM and a 128MB of swap space you'll be able to run a light GUI environment but have a crappy filesystem cache. The system will crawl but it won't get constant OOM errors if you're not overzealous with your app usage.

    The 2x RAM rule on a system with 512MB of physical RAM on the otherhand is excessive. With 1GB of swap space most of it will end up empty unless you're running programs needing huge amounts of allocated memory. With more than 512MB or more of physical memory on a single user workstation you're pretty unlikely to run into situations where active pages are swapped out to disk.

    I've seen the runaway process situation crop up on more than one system with excessive amounts of swap space. Since swap is so slow it can be troublesome to kill a process that is using so much memory that it ends up having active pages swapped to disk. The system ends up spending 99% of its time trying to handle the disk IO from the heavy swapping which can make the system totally unresponsive for local and remote users. Because the systems had way more swap space than was logical the offending processes never got OOM errors even though they were using up almost all of the system's resources.

    I've pretty much set 256MB as the upper limit for my systems with 256MB or more of physical memory. That is enough swap space to hold any dirty pages or unused processes but not so much that a runaway process is going to eat up all my disk IO for a couple of hours. Once a system hits the 256MB threshold I toss out the silly 2x RAM rules for something with a little more cognitive thought.

    --
    I'm a loner Dottie, a Rebel.
    1. Re:U R N Idiot by Skapare · · Score: 1

      The amount of swap space to configure should be based not on the size of your RAM, but the speed of your hard drive and transfer bus. Choose a size that can be swapped (in or out) in less than 10 seconds (or whatever your level of tolerance is).

      --
      now we need to go OSS in diesel cars
    2. Re:U R N Idiot by vadim_t · · Score: 1

      It's not that easy.

      The big problems happen when you have WAY too much *active* stuff at the same time. Then the kernel has no choice but to swap out one thing, swap in another, swap it out, swap in something else... The way of avoiding that is having your swap small enough to make things crash due to lack of memory before this situation can happen.

    3. Re:U R N Idiot by ameoba · · Score: 1

      What's this obsession with "runaway processes"?

      Unless I'm intentionally writing a fork bomb, I almost never see them on my system. If you're arguing for some sort of multi-user system, use resource quotas. Limiting swap is not the right way to solve this problem.

      --
      my sig's at the bottom of the page.
    4. Re:U R N Idiot by Skapare · · Score: 1

      Crashing is an unpleasant thing. But so is thrashing. Of course you need to have enough RAM to handle the things you are doing. Swap can then be used for "peak shaving" for those not-so-often times when you exceed expected needs. One problem is that when processes do a lot of disk writing, the Linux kernel tries to write things to RAM first, then later to disk ... preferring to write "idle" process memory to disk (swap) first instead. Linux needs to have a limit on the amount of RAM used for write caching, and a reserve of RAM for process memory only. I want to be able to keep the normal amount of processes in RAM regardless of how many hundred of gigabytes a few of them are writing to disk files.

      --
      now we need to go OSS in diesel cars
  39. Graceful degradation by Sigl · · Score: 1
    That's what Roger Luethi said and that might be the only angle I view swap. For a server it might be good practice to always degrade gracefully (meaning to always have a swap file) But whenever I notice my workstation start to swap I usually end up killing whatever was causing it disgusted the whole time because the system is responding so slowly it takes several minutes just to kill the process causing the slowdown and knowing that every second it spends swapping stuff out is another second I will have to wait for stuff to swap back in after this process dies.

    Makes me wanna go out and buy more ram just thinking about it.

    1. Re:Graceful degradation by xyote · · Score: 1

      If only the degradation was graceful. You hit the tipping point in system usage and with round robin scheduling suddenly the LRU page replacement algorithms don't work so well and Denning's law kicks in with a vengence.

      The problem is system performance is queue based and the queue service times are different depending on whether processes/threads have to wait. If they start waiting then suspend/resume overhead gets added to the queue service times. You get a hysteresis effect on you performance curve. This means your system load has to be reduced dramatically before you see a return to normal performace levels.

      It's not just overuse of memory that can cause this. Heavily threaded applications can suffer this because of queueing on locks for sharing. Use of lock-free algorithms helps because they don't use wait queues by definition.

    2. Re:Graceful degradation by Anonymous Coward · · Score: 0

      I know it's gonna be slow but your alternative is a system that does nothing but throw errors. Compared to that swap certainly is graceful.

  40. swap on ram by Anonymous Coward · · Score: 0

    Yes, it sounds crazy. But not too long ago, somebody here on Slashdot posted something about an IDE device wherein you could put RAM on that thing and access is as if it was an ordinary IDE device. YEs, compared to your memory bus, the bandwidth sucks, but its not really bad compared to hard drives, especially the hard drives' seek time.

  41. "Swapiness" by Compholio · · Score: 5, Informative

    If you've got kernel 2.6 you can change the "swapiness" to fit your needs/desires. People with lots of RAM could experiment by changing the swapiness value to 0 and report back with the results (be easier than installing a system without swap).

  42. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  43. Best of both worlds by Anonymous Coward · · Score: 0

    1. Make a ramdrive
    2. Create swap file in ramdrive

  44. I can sympathize... by zx75 · · Score: 1

    With being annoyed at a system that takes some time to load applications back into memory from disk after being idle for some time, despite not having used up available memory and the OS deciding to swap it out anyway. And there is merit in the idea that an OS shouldn't swap something out of memory unless it needs the space.

    However, the idea with doing away with swap space entirely, I'm sorry but what are some of these people smoking? "I have 256MB of physical memory, and 256MB swap space, a hard cap of 512, if I add 256MB of new real memory, and could remove the swap space I'd have the same amount of memory and better performance!". No, you're wrong, you'd have MORE memory at the cost of money from your pocket and better performance than you used to, but you won't be able to run any more applications than you could before by having more memory.

    I would support the idea of on demand swapping, only sending least used memory to the harddrive when absolutely necessary, instead of when convienient. It would definitely improve performance of bring back up those idle tasks, and degrade slightly the performance of opening new applications when memory is almost full. However, doing away with it entirely would be a BAD design decision for an OS to make. The whole point of swap is to increase the amount of usable memory without having to buy more memory. Just because RAM these days is seen as 'cheap' does not limit either the desirability of that feature, nor the necessity of it for those people who haven't tricked out their systems. Because you consider 4 gigs of physical memory cheap and a necessity, does not mean everyone else can afford it.

    --
    This is not a sig.
  45. You mean.. by Azureflare · · Score: 1
    As long as there are buggy apps that get memory leaks and suddenly consume all available RAM and start swapping like mad.

    Yeah, that's happened to me in kde (quanta) in Mandrake 10 CE. I was sure glad I had a swap space then.

    BTW I've got a gig of ram.

  46. Swap sucks. :) by MikeFM · · Score: 5, Insightful

    I've built many servers, embedded systems, and even desktop systems that don't use any swap at all. Many more I limit the amount of swap greatly. The overall responsiveness is much better if you don't use swap and I find system stability to be better. Really it doesn't matter what the systems are used for or how many apps are being ran.. it's just how much memory you're going to use compared to the amount of physical memory you can afford. You can run out of memory just as easily using swap as you can while limited to physical memory.. the main difference being that the recovery of the sitution is much worse in the case of using swap. Quite often the system starts to churn and then grinds to a halt. Without swap those tasks just die and everything else keeps running. Setting memory limits on tasks is a good way of ensuring which tasks are killed first but I'd like to see better control of this given to the admin.

    --
    At what price learning? At what cost wisdom? The price is a man's peace of mind, and the cost is his life.
    1. Re:Swap sucks. :) by oolon · · Score: 2, Insightful

      There are good reasons for swap, for example when a program forks, You need spare ram for the complete process space, this space normally comes from swap, before being wiped out when a new command is execed. Another good thing to do with swap space is use tmpfs and use it from /tmp, that way if you have lots of memory /tmp will come from memory not disk, and if your stuck for space your use the swap space.

      James

    2. Re:Swap sucks. :) by gfxguy · · Score: 1

      I still haven't seen a good reply to what one of the people asked after the story...

      If I have 256MB RAM, and 256MB swap, everything is fine and dandy, and everything I need to run works just fine without running out of memory.

      So now I replace the 256MB swap with another 256MB RAM. In both cases I have 512MB of memory available to the system.

      So what, exactly, is the problem?

      --
      Stupid sexy Flanders.
    3. Re:Swap sucks. :) by Colin+Smith · · Score: 1

      Isn't that obvious?

      The problem is when you have 512 Mb of RAM and some twat sends you a powerpoint email giving you 513Mb of running applications.

      --
      Deleted
    4. Re:Swap sucks. :) by Malc · · Score: 1

      Memory limits on processes? That's funny, that used to drive me nuts on the Mac. When I was using them at university in the mid-90s you had to decide how much memory to assign before running the app. Get it wrong... well, bad luck. I hated it.

      I'd rather not have my servers killing tasks due to low memory conditions. Swap gives me a chance to figure out what's wrong and try to rectify it. For sure you've got a major problem on a server if you've run out of memory and you should never hit that condition If it does happen on a production server, you need a chance to determine why and without harming the clients. Poor client performance for a short period of time is better than no performance or loss of data or state (dependent upon your applications I guess).

      We're mostly a Windows shop, with a small number of Linux servers too. The Linux servers seem to give you more rope to hang yourself and also to be more crippled when they get in to a thrashing condition. We've had mistuned on them and when they've been memory starved thrashing has made them impossible to even log on remotely via ssh leaving the only option to telnet in to the power supply or have somebody go down to the colo. Yes, I know there's ways of setting resource limits (I've read in the Debian documentation although these are Red Hat), but we didn't have time nor sufficient experience - hey I'm software engineer not IT guy (cop out I know!), I shouldn't be covering the servers anyway! ;) The Windows boxes OTOH in the same condition seem to just get more and more sluggish but still keep serving slowly and there are never any problems logging in via RDP/pcAnywhere/VNC, although that might take 15 mins (which is fine when you're 5,000km and don't want to trip the power switch).

      Of course, these are my experiences. Somebody more profficient with Linux than Windows might have the opposite opinion! But as I said, I do get the impression that Linux gives you more rope to hang yourself (i.e. easier to misconfigure) and the consequences seem much worse. Then again, we've never had services crashing randomly under Linux due to the latest worm du jour ;)

    5. Re:Swap sucks. :) by Colin+Smith · · Score: 1

      Yeah, almost everything you've said is shite.

      Overall responsiveness doesn't make any difference if you add swap to a machine which has enough memory in the first place.

      System stability is worse without swap because when you do run out of memory, *random* processes are killed as they attempt to allocate RAM. Those processes can be *anything* running on the box, not *just* the memory hogs. Everything else does not keep running.

      It's N times as hard to run out of memory while running with swap, because you have N times the amount of memory.

      For the uninitiated. Swap is like a spare tyre. It's something you should have, but something you should try not to use except in emergencies. If your system is paging, add more RAM and allocate it to whichever applications need it.

      The difficulty with desktop systems is predicting the usage, how big is that email, what happens when you open a 200Mb powerpoint. Therefore swap is required.

      --
      Deleted
    6. Re:Swap sucks. :) by Dr.+Evil · · Score: 1

      There isn't much of a problem per se, you're just not using your RAM efficiently.

      Libraries, data or other memory pages which are accessed infrequently will stay in active RAM, when in theory, it would be better if the RAM were acting as a HDD cache.

      In practice, it depends on how agressively your swapping is tuned. A super non-aggressive swap algorithm should give you faster disk access and and a lot more available RAM.

      Try adding swap and tuning your swap characeristics. You'll run out of memory less often and you probably won't notice any other differences.

      Another way to look at it is... RAM is your primary storage. Your HDD is your secondary storage. By eliminating swap, you're putting unnecessary demands on your secondary storage by artificially favouring rarely accessed information. E.g. if you're reading your mail in X, you'd be better off storing your mail file in RAM than the libraries which allow acroread to print on pink paper, or your gpm shell application.

    7. Re:Swap sucks. :) by gfxguy · · Score: 1

      What you're saying is that swap is being used for inefficient memory storage instead of wasting the more valuable RAM for that purpose.

      What I'm saying is if I have enough RAM, then the whole point is that it's there to waste. Obviously.. it's like having a >1Ghz processor to read email and surf the net, even most multimedia applications don't require that much processing power, and so most of it gets wasted.

      So you have all this extra RAM... a lot of it is going to just stay there, stagnant, with information that would otherwise be in swap. However, if you have the RAM to waste, then why not use it?

      In your argument, you are implying that swap is somehow an intermediate between primary (RAM) and secondary (HDD) storage, but swap is HDD, and while it might be more efficient HDD, it's still the same old relatively slow storage medium.

      So, let's get back to my question... let's say that I am going to have 512MB of memory either way. It's obviously better to have 512MB RAM and no swap. I'm not saying having swap over and above will hurt, but I'm asking that, if 512 was sufficient before, then isn't 512MB RAM without swap better than 256 of each? And if the argument goes that keeping that 256MB swap partition would still help, then wouldn't it still be better to get another 256MB of RAM? And so on and so on... until you say "you can only have so much RAM", but I can counter that at that point, none of that memory is being used for anything... it's all just being wasted... so the idea is to find out some reasonable extreme, monitor your system, see that running all of your applications you might have running at the same time takes 450MB memory, and say "OK, I'll get 512MB and have no swap."

      --
      Stupid sexy Flanders.
    8. Re:Swap sucks. :) by gfxguy · · Score: 1

      I thought of a different way to approach the discussion. So let's go back to 256MB of RAM, and 256MB of swap.

      Now let's say that I see the computer is swapping (not thrashing, just swapping), and so I put in another 256MB of RAM and (as a ridiculous argument) tell Linux to use 256MB as a ramdrive for swap space (if that's even possible). I also remove the hdd swap space.

      Would my performance improve using a ramdrive over HDD? Of course it would! Would it improve even more if I just used 512MB instead of having the overhead of using a ramdrive? Of course it would (even if only marginally).

      The counter argument I can accept is that swap space is still good because it gives you even more memory should you need it, which no one can really argue against, but I somehow can't buy that, under normal circumstances, merely having enough RAM isn't efficient (speed wise).

      --
      Stupid sexy Flanders.
    9. Re:Swap sucks. :) by SillyNickName4me · · Score: 1

      Your poitn seems to be that when you have 512mb total (regardless of what part of it is ram) and you try to use 513mb, you run out of memory. Of course that is true.

      The problem is that 1mb swap is a lot cheaper then 1mb ram. Ie, for a certain oprice, you could afford 512mb ram, or 256mb ram and 8gb swap.

    10. Re:Swap sucks. :) by oolon · · Score: 1

      The point is, you have 512 meg of memory the program you are using is supper massive and takes 300 meg of memory, it now wants to run another process to do this it needs to fork, then exec the other process which is tiny, 5 meg thing... However at the moment of your fork you MIGHT require 600+ meg of memory... Good night your out of memory, even though at "normal" levels your not. However with swap space you have it allocated and it will work if needed but be a bit slow. However in this case it will NEVER be needed. This of it as ironing out the peeks. Any system that is regularly using swap as main memory though will have problems.

      Personally I have a gig of memory and 1/2 gig of swap.

      James

    11. Re:Swap sucks. :) by EvanED · · Score: 1

      "isn't 512MB RAM without swap better than 256 of each?"

      Yes, it is. Essentially always. I can think of no exceptions.

      However, let's take this from a practical standpoint. The reason you'le likely to upgrade is because RAM prices are dropping and you've had your computer for a little bit. However, at the same time, memory usage of applications is growing. So while 512 MB of ram may have been enough when you had only 256 MB of ram, maybe now it isn't.

      Besides, the question you're asking is a bit of a red herring. It doesn't really matter if 256/256 is slower than 512/0, because you might see an increase in performance if you switch to 512/512 or something else. Maybe not. But the leeway would then be there. Hard drive space is cheap enough--much, much, much cheaper than ram--I see little reason to not add swap in as security against the occasional time you happen to have two X servers running at once, Mozilla on one, Firefox on the other, OpenOffice on both, then you go and start compiling and oops, now the kernel has killed OpenOffice because it ran out of RAM and you lost an hour of unsaved work. ;-)

    12. Re:Swap sucks. :) by afidel · · Score: 1

      Here's an idea, mod the kernel to kill process's by niceness level when you fail on a page allocate. That way you Oracle database is the last process to get killed and that cleanup script or indexing process is among the first. Btw I'm of the opinion that for critical servers if you EVER go to swap you've already failed. Responsiveness takes such a dive that the server usually needs to be rebooted anyway. Of course it might give you the ability to do a clean shutdown instead of just panicing.

      --
      There are 4 boxes to use in the defense of liberty: soap, ballot, jury, ammo. Use in that order. Starting now.
    13. Re:Swap sucks. :) by 0racle · · Score: 1

      You can never plan for everything, swap is there as a safety net. Anything from unanticipated loads, (a kickass site that shows up on Slashdot perhaps), or a bug in what ever applications your running on it can quickly monopolize your ram, and down things go. Obviously you never want to plan to use swap, and you size the system to what its going to do, with some leeway, but its impossible to plan for everything all the time.

      --
      "I use a Mac because I'm just better than you are."
    14. Re:Swap sucks. :) by gfxguy · · Score: 1

      But if I used 600MB before I would have been screwed anyway... remember, I'm talking about regular usage with 512MB total memory, never having a problem of running out of memory, and the question becomes isn't it better to have 512MB RAM as opposed to 512MB of 256MB RAM and 256MB swap?

      Obviously, with the size of drives these days, I wouldn't bother reclaiming a measily 256MB of disk space, but the point is that, for speed, it's always better to have RAM. If you run out of RAM using a particular application, you can get around the problem by adding swap, but ultimately, for peek performance, it'd be better to add more RAM.

      --
      Stupid sexy Flanders.
    15. Re:Swap sucks. :) by gfxguy · · Score: 1

      Well, of course, I agree with you, but theoretically, if you have X amount of RAM and need more, then for the absolute best performance it would be better to get more RAM then add swap. The question isn't about speed/money, it's purely about fastest performance. I'm not saying I'd do this, but it's the logical extreme of the argument that a system with swap always performs better... if you put enough RAM in your system, that's obviously not true.

      --
      Stupid sexy Flanders.
    16. Re:Swap sucks. :) by Sj0 · · Score: 1

      Yes, a lot of things SHOULD work in a certain way, but right now, they DON'T. I've been running without swap for about a week now for a few reasons, on a dual boot win2k/gentoo linux box, and it IS faster than running with swap turned on. I must have enough ram to do what I want to do though, because I'm writing to you right now sans swap. The problem is that VMs aren't perfect, and neither are VM devs. In trying to ensure that there is an extra 10MB of disk cache available, they end up sending stuff to swap long before there's a legitimate need, completely negating, in my view, the point of that 10MB of disk cache in the first place.

      And as for your other point, swap in Linux isn't allocated automatically, it's got it's own partition. If you run out of swap, and you've run out of memory, you're going to be just as toasted as if you ran out of RAM and had no swap, except a lot slower. Sure, you could have that extra swap both ways, but if you have more than enough ram(for example, if I decided to put 1Gb of RAM into this box -- my gentoo partition is only 1gb overall!!), it seems it would be a lot faster to hold everything in memory, and for a mobile user such as myself, it seems to me that forgoing the disk activity caused by swapping in and out would save battery power as well.

      --
      It's been a long time.
    17. Re:Swap sucks. :) by oolon · · Score: 1

      No, you miss understand completely, when forking, the address space is allocated however it is not used until a page is needed at which time it is copied (infact it would be copied to memory and something else mapped to disk). Allocated is not the same as copied! If you execing right after a fork memory is never touched so the copy never occurs hence your disk is as fast as RAM! The point is at forking you process splits in two, so it becomes double the size it was, normally right after that it becomes very small as it turns into something else. Its all about address space. Having more real memory would make NO difference to your system what so ever, it has to work that way because the kernel does not know your not going to use the memory! Having 512 Meg and no swap will mean your system will start to become unusable at the 450+ mark (depending on what your doing), with swap you could use right up to the 512 Meg point.

      To answer your question it is only better to have 512 meg of memory if you use more than 256 meg! If infact you use 250 meg of memory, its cheaper to have 256 meg and 256 meg of swap. Forking processes will spike you over the 256, but the extra 256 meg NEVER ever actually be used.

      Having swap space means you get to use all your ram for programs etc, having no swap space means some of your ram will be wasted as some address space is required in transient operations.

      In a workstation else days thats a bit mute, but on a expensive multi-cpu server nmot being able to use all your memory is very costly.

      James

    18. Re:Swap sucks. :) by Setsquare · · Score: 1

      Seymour Cray quote on virtual memory: "Memory is like an orgasm. It?s a lot better if you don?t have to fake it."

    19. Re:Swap sucks. :) by MikeFM · · Score: 1

      Which is why you set a memory limit on all non-root users so if they run more than x amount of memory then their apps die. Your email app goes away complete with powerpoint crap and nothing else gets hosed.

      --
      At what price learning? At what cost wisdom? The price is a man's peace of mind, and the cost is his life.
    20. Re:Swap sucks. :) by MikeFM · · Score: 1

      So it's better not to be able to fix a problem than to have to decide in advance how much memory you want to use, max? I think they need better tools for on-the-fly adjustments but setting a max limit should be easy enough to do in advance.

      Your server is going to kill tasks due to low memory conditions regardless as to how much memory you have and to how much of that is physical and how much is swap. Using swap just makes the behavior worse when it happens. Using limits just gives you more control over what gets killed. Sure you never want to run out of memory but you should prepare for every possible problem on any important machines. If you don't notice the problem before you use up the 4GB of ram your server has then you just weren't paying attention.

      Certain Linux kernels have a bad thrashing problem but that's been fixed for quite some time. It's still worse, with any OS, if you use swap.. especially a lot of swap. I'd suggest upgrading your kernel if you're having severe trashing problems with your systems. If it still thrashes then you have a severe problem and probably need to add physical memory and audit the apps you're running. I've always seen Windows servers go down under much less stress than Linux servers excepting those certain kernels which did have a problem. It could be in how your apps are using the systems too.. how well your apps respond to low memory situations.

      Linux does give you more rope to hang yourself but it doesn't come with a noose around your neck. I do think that distros are badly installed in general though. They don't do a very good job at installing for specific problem domains. Not that I think Windows does either but Linux should, and can, do a better job. For my servers I prepare a custom installer that installs just what is needed for the task needed and is pre-configured to do the job right. I think Debian, RedHat, etc need to do something similar.

      --
      At what price learning? At what cost wisdom? The price is a man's peace of mind, and the cost is his life.
    21. Re:Swap sucks. :) by MikeFM · · Score: 1

      No, swap is like trucks that have double tires. It runs on them all, all the time, which helps should you need them but at the cost of impacting your effeciency all the time and being some risk in itself to reliability. I usually keep a swap partition but leave it switched off by default and keep it there only should I see some task running away and I need emergency memory while I fix it.. closer to your spare tire concept I think.

      Overall responsiveness is impacted by swap.. regardless as to how much physical memory you have. The more swap you have the more it'll impact the machines performance. Certain things try to use swap first, which slow the machine down, and the more swap you have the more effort the machine goes through to manage it.

      You shouldn't run out of memory with or without swap because if you do, either way, then random processes are killed. If you can't afford enough physical memory then swap can be beneficial (sometimes running badly is better than not running at all) but when possible you want to run in all physical memory. Wait until you have 4GB of stuff swapped on a system with 128MB of physical memory and then tell me that system stability is improved by swap.

      --
      At what price learning? At what cost wisdom? The price is a man's peace of mind, and the cost is his life.
    22. Re:Swap sucks. :) by Anonymous Coward · · Score: 0

      So one could say: If you KNOW in advance, exactly how much memory your system will require and you install that amount of RAM, then you will not need swap-space. But if you can't KNOW in advance, or if your requirements change before you are able to budget, power off and add more RAM, then you will need to have swap-space on hand to avoid partial (or total) application malfunction and the potential customer/liability that goes with it.

    23. Re:Swap sucks. :) by Dr.+Evil · · Score: 1

      In your argument, you are implying that swap is somehow an intermediate between primary (RAM) and secondary (HDD) storage, but swap is HDD, and while it might be more efficient HDD, it's still the same old relatively slow storage medium.

      There's a relationship between swap and cache which you seem to be neglecting.

      Some stuff in RAM is so thoroughly unused that for performance, you'd be better off dynamically allocating the RAM to cache than to have the RAM sit idle.

    24. Re:Swap sucks. :) by tricorn · · Score: 1

      Of course, there are other ways of doing that. One is to turn on overcommiting memory (which was the default once-upon-a-time). The other is to use vfork(), which basically says "I'm just gonna exec(), so don't bother allocating for me all of my parent's memory space". I know at one time in Linux, vfork() was the same as fork(), but at least in current kernels/glibc, it definitely is different.

      Now the problem with overcommit is if you actually try to use memory that was speculatively allocated to you, but now is not available. In that case, a random process can get killed, which is usually undesireable. But there's not much downside to vfork(), as long as you do in fact exec() right afterwards.

  47. swap sucks with 2k & xp - disable it if possib by Festering+Leper · · Score: 3, Interesting

    there's a definite pattern with regard to swap in the windows world.

    for win'9x: use up ram until almost gone then start allocating swap space in anticipation of actually using it. should memory allocation still be increasing then actually use swap space. reverse the order when freeing memory.
    i had 384 megs ram at the time and as long as i used less than about 350 megs total the system wouldn't be in swap.

    for win 2k & xp: (when within physical ram limits) whatever amount of memory is requested, allocate between 60-80% to ram and the rest to the swapfile. even the disk cache partially goes to swap! i didn't believe it at first but all one has to do is look at the numbers in the task manager's memory/cpu window. at first i figured that all i'd need to do is throw in some more ram and the disk thrashing and absolute crawl would go away. i put in a gigabyte of ram (i never allocate more than 700 megs at most and the total system memory usage on bootup is 100 megs). even with the extra ram the problem stayed the same.

    turning off swap gives me consistent fast performance, and since the disk cache isn't swapped (partially) i get 2x the throughput i had with a swapfile on large file copy operations

    machine tested: duron 1.3ghz, 1 gig pc133 ram, 2x 80 gig wd800jb hdd.. os win2000 & winxp running newsbin which allocates disgusting amounts of ram in a large header grab (yeah i could have used a test program but why do that when newsbin is a real-world test for me). the os and applications are on different drives on their own ide chains

    with swapfile enabled (size=1.5x system ram).
    allocation time: unaffected, only the time to perform task reqested
    memory de-allocation time: (by either quitting app or selecting another group) 23 MINUTES of constant disk thrashing

    with swapfile DISabled
    allocation time: unaffected, only the time to perform task reqested
    memory de-allocation time: (by either quitting app or selecting another group) 2 seconds

    --
    if you want people to think you know what you are talking about, just put ".com" at the end of everything you say.com
  48. why not have swap? by Anonymous Coward · · Score: 1, Interesting

    For most home users who can get 200+ GB of disk relatively inexpensively what's the big deal about giving up (say) 1GB for swap?

    There's also the use that if for some reason a system panics (hey, it happens) you have a place for the kernel to dump to. This can be valuable in helping debug what happened with a backtrace.

    1. Re:why not have swap? by pe1chl · · Score: 1

      Sometimes a valid reason can be that the disk can sleep when it is not accessed, and would need to startup (takes time and wears it out) every time a swap page is touched, which occurs randomly.

      This is not a very likely scenario in a general purpose PC, but I do have a TV satellite receiver that runs Linux and normally runs without swap. It uses the disk only for video recording, but there is an option to add swapspace on that disk.
      This does not work well because the disk is almost always asleep (when you are just watching TV) and it is a nuisance to have it startup at random moments, or when you press some non-recording button on the remote...

  49. We really need to repurpose the sticky bit... by StevenMaurer · · Score: 1

    The sticky bit on Unix systems keeps the image of an excutable from abandoning the swap space image when the last user has stopped running it. It speeds startup time of selected applications in a heavy multi-user environment. Not very useful feature anymore.

    What would be really cool is to repurpose this bit to tell the OS to not page out the application instead.

    That way you could have all the benefits of swap, but your U.I. programs (with this bit set) could still give you snappy response because they'd always be in RAM. Call it a "half-swap" system.

    Linus, you listening?

    1. Re:We really need to repurpose the sticky bit... by Have+Blue · · Score: 1

      Then, sooner or later, your total usage by active apps would exceed your physical memory, and either you'd be unable to launch a new app or existing apps would start crashing as they are denied mallocs. There's no way to make room for a new allocation if 100% of the physical memory is marked as not swappable...

      Most modern OSes do mark some parts of the kernel as unswappable (I believe the term is "wired down"), but this is done only where it's absolutely necessary and for the minimum amount of data possible.

    2. Re:We really need to repurpose the sticky bit... by cpghost · · Score: 2, Insightful

      Please don't touch the sticky bit semantics. They are still used on other Unix-like systems (though rarely) and having different meaning in Linux is just calling for trouble.

      A better way would be to use other file attributes. On FreeBSD you can use chflags(1) to set flags like arch, opaque, nodump, sappnd, schg, sunlnk, uappnd, uchg, uunlnk. It is IMHO always better to add more flags in a specific filesystem implementation, than to break backward compatibility without very good reason.

      --
      cpghost at Cordula's Web.
    3. Re:We really need to repurpose the sticky bit... by pe1chl · · Score: 1

      This would probably not work as well as it did in the PDP-11 days.

      Then, a program was a single file that was always loaded in memory as a whole.
      Nowadays, the system uses virtual memory (so the program is not loaded all in RAM, but only the parts that are actually used are loaded).
      And many programs consist of a main program and some or many dynamically loaded libraries.
      Would you propose that all of these would be loaded into RAM? And would the sticky bit have to be set on each of these, or would the bit on the program itself imply that all its libraries would have to remain in RAM as well?

      Don't you run the risk that newbies would set so many sticky bits that there main applications can remain loaded, but the remaining RAM is too small to accommodate the many other processes in the system, forcing these to swap and to cause disk performance problems for the main applications as well?

      Some manual management capabilities can be nice, but they require competent administrators. The wide use of computers without any competent administrations has brought the (Internet) world where it is today, in an ever worsening virus and worm disaster. I don't think relying on competent administration is a good plan.

    4. Re:We really need to repurpose the sticky bit... by pe1chl · · Score: 1

      In Linux, the entire kernel is unswappable.

  50. I always have 2G swap by menscher · · Score: 4, Interesting
    Why not more? Because that's the largest a swap partition can be. Why not less? Because disk is cheap. It has little to do with the amount of ram in the machine either, because it's easy to add more ram, but a bit harder to repartition for more swap.

    Here's a real-life example of why swap is useful. One machine I manage has a gig of ram. At the time of purchase, that seemed quite reasonable. But the users are working on a project that takes 2 gig of ram. So currently it's using a gig of the swap. Yes, that's bad, and I'll be adding a second gig to it in a few days (it's in the mail). But in the mean-time, that swap space is really handy. It means the users can get their work done! Think of the first 256M of swap as being for speed. If you're regularly using more than that, then it's time to order more ram. But it's nice to have the spare gig of ram for odd jobs, or while you're waiting to install it.

    I'm no expert, but I think a lot of these arguments could be resolved if people took advantage of the ulimit constraints. If you can limit how much a program can get out of control, then there's no longer a concern for a single user sending the server into swap hell. One of my current projects is to figure out reasonable limits.

    1. Re:I always have 2G swap by ananke · · Score: 3, Insightful

      "Why not more? Because that's the largest a swap partition can be"

      Just a side note: you can have multiple swap partitions. [not that you need them, but you can have them].

      --
      --- d'oh
    2. Re:I always have 2G swap by grotgrot · · Score: 1

      I have 5GB of swap. I have /var/tmp and /tmp as well as the RPM build (on Redhat) (/var/tmp/portage on Gentoo) as tmpfs. That basically means those filesystems are backed by memory and swap. Compilation speeds are significantly improved and as real RAM fills up, less used tmpfs stuff ends up in swap.

      The swap is on 2 x 2GB partitions and 1 x 1GB partition. Normally all drives except the first one are powered down.

    3. Re:I always have 2G swap by Corydon76 · · Score: 1
      Unless you're on a 64-bit platform, or something that can manage more than 32-bit memory (i.e. Xeon), 5GB of swap is unnecessary. It's also wasteful, although wasting 1GB of disk space is hardly notable, given how much other diskspace you have.

      Why is it wasteful? Because on 32-bit systems, you have a maximum 4GB of memory. That's the maximum that is addressable, period. There aren't any more addressable pages of memory, so there's no way to have a page fault (which triggers the OS to load the swapped page of memory) beyond 4GB.

      In fact, if you have 4GB of memory on a 32-bit system, you do not need swap, as it will simply be unused! (no page faults possible)

      P.S. Some of you may be wondering about the Xeon comment above. Xeon uses a trick that allows it to address (IIRC) 36-bit memory, which would give it a maximum of 64GB of memory.

    4. Re:I always have 2G swap by rokicki · · Score: 1

      You don't understand virtual memory and processes. Go back to Unix 101. It's not tough to use tens of gigabytes of swap on a 32-bit, 4GB RAM system.

      Also, linux supports swap partitions larger than 2G for some time now; I almost always run a single 20GB swap partition and it works just fine (and yes, frequently I do use tens of gigabytes of swap). Of course, I do unusual things with my system.

    5. Re:I always have 2G swap by grotgrot · · Score: 1

      You are confusing several things. Swap is not RAM and is not addressed in the same. Nor is swap "mapped" above RAM with 4GB limits or anything else like that.

      You also completely missed my point as to why I do it. tmpfs comes out of memory and swap. Having the various filesystems I mentioned coming out of them is a LOT faster than straight forward disk. Much of the stuff I compile has huge source and build trees. I also run UML a lot, and it uses tmpfs files as "memory".

    6. Re:I always have 2G swap by Elladan · · Score: 1

      Furthermore, if you have more than one disk, multiple swap partitions are a good idea. The kernel will stripe between them, so swap will go faster.

      If your disks aren't all the same speed, you can even specify priorities for which one(s) to use first.

    7. Re:I always have 2G swap by Witsu · · Score: 1

      I found on my 300Mhz box with 384 ram running XP that having a relatively large (2gb) swap file actually helped performance while playing back Divx encoded movie files. When I used the recommended 1.5x amount of ram for swap the video played out of sync with the audio, but using 2gb of swap it played in sync.

    8. Re:I always have 2G swap by Corydon76 · · Score: 1
      You're incorrect. I do understand virtual memory. What you apparently do not understand is how an OS is prompted to swap a page of memory back from disk (in terms of the machine architecture).

      The problem here is that virtual memory is mapped one-for-one onto physical memory (this is only true when your physical memory matches the maximum amount of addressable memory -- on 32 bit systems, 4GB). Unless you have unavailable memory pages which can be 'stepped on' (which triggers a page fault), you could certainly swap memory out to disk, but there would be no page fault signal to trigger that memory to be swapped back into physical memory.

      To clarify, this is not about Operating Systems or Unix, this is about the underlying processor architecture. You simply cannot have page faults if physical memory equals virtual memory!

  51. Swap = 0.5x RAM for hibernating by Henk+Poley · · Score: 1

    Not to be a smart ass or something, but...

    I think a modern Linux desktop system with plenty of RAM needs at least half the amount of RAM as swap, to accomodate hibernating. With swsusp2 moving into the kernel 'soon' there is no need to shutdown your programs even if you shutdown your machine.

    And even with 1GB of RAM you will need some swap, I happen to fill 600MB swap with a system with 512MB RAM. Just some browser apps, email and from time to time th Eclipse Java IDE.

  52. BillG and 640K by steveha · · Score: 4, Informative

    Bill Gates never made the infamous "640K... enough for anyone" comment. Not only have I never seen it documented anywhere, but he was asked about it and replied that he never said that.

    He didn't see the Internet coming -- he thought MSN should be like CompuServe, because that was the top info service (before the Internet became big). And I remember some wild comments he made about the truly amazing, throbbing power of the 286 chip. So he's not an amazing guru with awesome predictive powers. But people keep beating him up about this bogus quote, and I'm tired of it.

    steveha

    --
    lf(1): it's like ls(1) but sorts filenames by extension, tersely
    1. Re:BillG and 640K by Anonymous Coward · · Score: 0

      Well maybe he didn't say this quote but I'm still laughing my ass off about when he claimed he invented the internet!

    2. Re:BillG and 640K by edunbar93 · · Score: 1

      Not only have I never seen it documented anywhere, but he was asked about it and replied that he never said that.


      Yeah, well *someone* clearly made that decision, and it affected end users and programmers all the way up until windows 95 and direct X came along, since the design of DOS dictated that you had to sacrifice a chicken and chant an incantation every time you used a program that needed more RAM. Which by 1992, was *every* program.

      So while I'm sure that Bill Gates isn't lying to us all about that, he was the guy responsible for the design of DOS, and he *did* decide that 640K is enough for everyone.

      --
      "No problem. I have the capacity to do infinite work so long as you don't mind that my quality approaches zero."-Dilbert
    3. Re:BillG and 640K by rugger · · Score: 1

      Bill Gates did not decide on the 640K limit in DOS.

      This limitation was fostered upon us by Intel, who designed the 8086 processor, with a 20 bit address bus (1 meg accessable memory space). It was then endorsed and solidfied by IBM using intel's processor, and only allocating the first 640K for memory, and the remaining 384K for ROM/video memory.

      DOS was merely written to utilize the system intel/IBM designed.

      Furthermore, it is rather harsh to demonise Intel/IBM for this limitation. The processor was designed in 1978, and the system in the early eighties. DOS persisted far longer then it should have!

    4. Re:BillG and 640K by steveha · · Score: 1

      Yeah, well *someone* clearly made that decision

      It's IBM's fault, really. Specifically, whoever at IBM designed the BIOS of the very first IBM PC. Maybe "designed" is too generous a word.

      The BIOS was supposed to abstract the hardware for you. You were never to access hardware directly, but always go through the BIOS. That way, if hardware changed, the BIOS could change too and you wouldn't have to change your code. But the BIOS wasn't good enough, and people began to ignore it and write their own code.

      The BIOS had a function that could move the cursor around, and it even had a function that could draw a single character on the screen. Amazingly, the BIOS had no function that could do both at once, and no function to draw a string. BIOS calls were slow on a 4.77 MHz 8088, and you needed to make two for each letter of a string to draw the string to the screen using the BIOS. Absolutely no one was willing to live with this. So everyone wrote code to just copy the string into the display buffer of the video card.

      Alas, you couldn't ask the BIOS for the address of the display buffer. So everyone just asked the BIOS what kind of video card (MDA, CGA, EGA, VGA, etc.) and then hard-coded in the appropriate address. When IBM was laying out the address space, they put the text buffer for a color video card at 640K, little dreaming that huge amounts of software would then hard-code that address, making it impossible ever to change it. (The original PC was available with 16K of memory, so no one was really worrying about apps too big for 640K at that time anyway.)

      If only IBM had designed the BIOS with a function that would give you the address of the video card, and everyone had used that instead of hard-coding the address. Then when 640K became a problem, they could have just released new video cards that parked the buffer higher in memory, and all the software would still work.

      steveha

      --
      lf(1): it's like ls(1) but sorts filenames by extension, tersely
  53. swsusp2? by Henk+Poley · · Score: 1

    Have you tried the swsusp2 patches? It uses gzip compression or the faster LZF for writing the hibernation image to swap.

    They can be found here:
    http://swsusp.sf.net/

  54. Before you complain at linux... by forgoil · · Score: 1

    ...remember how horrible the swap is in Windows (including XP). It really kills the resposivness to have large parts of most apps being swapped out. Especially if you leave the computer. Why swap a bunch of stuff out just because I am not sitting there and no program actually want any more (especially since I never use any other screensavers than "blank" or "turn of the monitor").

    I think the problem is basically that "seldomly used memory" is simply "a page not accessed in the last x time". I'm sure that a better system for a process can be deviced after all, and not having the startup code for the app in RAM isn't too bad, but swapping out everything needed to turn of the screensaver and start surfing/coding/gaming again really really pisses people off. Remember, it is about percieved speed.

    "If I have to wait, it takes too long".
    --Forgoil

    1. Re:Before you complain at linux... by pe1chl · · Score: 1

      What happens (also on Linux) is that while you are away, some background process runs that reads a lot of disk data. Things like a backup, the deamon for updating the database for locating files based on name and/or content, etc.
      This background process tempts the system to believe that it needs lots of pages for disk cache, and it better swaps out program memory.
      After the process is finished, disk pages remain in the cache and the programs remain on swap, until you touch the mouse.

      The system should examine the disk cache, the amount of free memory, the amount and age of swapped pages, and the activity of the disk.
      When the disk is idle and there is a lot of free memory and/or there are a lot of cached disk sectors that are not used recently, it could copy back pages from swap to RAM (maybe leaving them valid in swap as well until they are touched in RAM).

      Then, it can prepare for the user to start using the foreground programs again before he touches the mouse.

    2. Re:Before you complain at linux... by BigBuckHunter · · Score: 1

      emember how horrible the swap is in Windows (including XP). It really kills the resposivness

      Windows XP does not have a "swap" file. It has a page file. There is a difference.

      Thank you for your time,
      BBH

    3. Re:Before you complain at linux... by Anonymous Coward · · Score: 0

      What's the difference (besides the name)? I always assumed page and swap were the same thing. They sure seem to work the same to me.

    4. Re:Before you complain at linux... by BigBuckHunter · · Score: 2, Informative

      http://msdn.microsoft.com/library/default.asp?url= /library/en-us/dngenlib/html/msdn_ntvmm.asp
      Make sure to remove the space when you cut n paste

      BBH

  55. Reminds me of issues we had from Welchia by harikiri · · Score: 3, Insightful
    If I recall correctly, Welchia (the worm) looked for target hosts by ICMP scanning. On several of our cisco routers, the increased traffic resulted in them running out of memory, to such a point where you could not log into them.

    Apparently a new feature (mentioned by a network engineer workmate), is to have the IOS reserve a portion of memory for administrative tasks (like supporting the login process and configuration shell).

    A feature like this, that "reserves" a portion of RAM so that if something really fubars your system, you can still login to fix it - would be great for Linux/BSD.

    --
    Man watching 6 MSCE's around a sun box, looks alot like the opening scene's of 2001:space odyssey...
    1. Re:Reminds me of issues we had from Welchia by pe1chl · · Score: 1

      Well, in cases like this (the ARP table or some other network-related table of pending operations using up all available memory) it is just as valid to claim that the OS should limit the amount of memory spent on such things.

  56. This is stupid. You should have swap... by Anonymous Coward · · Score: 1, Insightful

    Just in case you need it.

    Although, I don't know what the big deal is. My OpenBSD server, which has 2 gig swap and 1 gig ram, hasn't actually USED any swap for more than 2 months. The server is used for email & an intranet site, with about 50 concurrent users.

    Of course, OpenBSD is dying, so what do I know...

  57. Photoshop Scratch Disk by havardi · · Score: 1

    When I found out Photoshop had it's own scratch disk, (swap file), I thought it was dumb, at first. There is a setting that sets how much available system ream Photoshop will suck up-- default is 50%. Without this, Photoshop would immediately saturate system memory and begin swapping, when you load a large image. Any program that knows it is capable of sucking up all the RAM should have a feature like this....

    1. Re:Photoshop Scratch Disk by harikiri · · Score: 1

      I've had Microsoft Movie Maker (2) crap out and use 1.6GB of virtual memory on me (on a 1GB RAM system). I've also had Azureus (java bittorrent client) using like 500+ MB of virtual memory (on a system with 256 real memory).

      It's becoming a real problem at work too. On my desktop system (has 256MB RAM), I typically have outlook, firefox, and checkpoint GUI clients running. Not to mention a few odd securecrt sessions. It's gotten to the point where I have to choose between outlook and checkpoint. Grrr.

      --
      Man watching 6 MSCE's around a sun box, looks alot like the opening scene's of 2001:space odyssey...
    2. Re:Photoshop Scratch Disk by pe1chl · · Score: 1

      This depends on whether the program can do a better job at memory allocation and swapping than the operating system.
      This may be true is specific situations, e.g. when the program knows it is done with operating on a specific memory page it can write it back and free the memory, whereas the OS will have to learn this by overseeing the situation.

      When the addressing space allows (64-bit system) it is possible to build an OS where the entire disk is in fact a virtual address space, of which the RAM is only a "cache". Programs can just access the disk as if it were memory, and the OS will handle all the reading and writing.
      With the possibility of "hints" from the application, this would probably work quite well for applications operating on lots of data.

    3. Re:Photoshop Scratch Disk by tilk · · Score: 1

      It's just a workaround for a problem of current operating systems, which have one swapping policy for entire system. If an application could itself decide, which pages should be swapped, and which should remain, this wouldn't be needed. And the OS technology, which enables per-process swapping policies, is of course the microkernel. For working for multiple-GB image data the problem could be also small address-space of 32-bit processors. To solve this, we should just go 64-bit.

  58. Re:You guys will hate my laptop. by czephyr · · Score: 0

    Ok, I'll bite. How fast is it?

    --
    Sincerely, Czephyr
  59. Just FYI by slittle · · Score: 2, Interesting

    I've run my Linux systems without swap for years (since 2.2) without any problems. Of course, I make sure I have way more RAM than I am likely to need (the stuff is practically free these days; but OTOH, so is HDD space.....).

    Simply put, you need enough 'memory' to hold all the stuff you want to run, plus caches. For a given task, you might go for a system with 512MB RAM and a 512MB swap, and I'll just go for 1GB RAM and forget the swap. The only difference is that if/when your system comes up on its RAM limit, it's going to start slowing down. When it starts using a lot of swap, it's going to crawl. But it'll still run. Until you run out of both.

    Mine will run like blazes upto the 1024MB limit, then barf. No warnings like with swap.

    So if you want an early warning sign, use swap. If your needs are well known and won't push beyond the limits of your hardware, don't bother.

    You can always add a swap file later/only the fly as your needs change anyway.

    dd if=/dev/zero of=/data/swap bs=1M count=512
    mkswap /data/swap
    swapon /data/swap

    --
    Opportunity knocks. Karma hunts you down.
    1. Re:Just FYI by pe1chl · · Score: 1

      This is not completely true. When you add some swap to your systems you will find that there is some margin where it will use the swap but not slowdown. This is because some processes allocate memory that they later (almost) never touch. This will be swapped out, and your RAM will be used for better things.

      I don't know how swapping to a file performs these days, but "back in the old days" (when swap was really required because you could not afford the RAM necessary) it was noticably slower than a swap partition.

      Just like you make sure that you have enough RAM, I make sure that I allocate a swap partition (on the first cylinders of the HDD) of 1-2 times RAM size. When it is not required, so be it. But my 1GB RAM system has 100MB of swapspace in use, and I have not run any very-large applications in the 41 days it is up.

    2. Re:Just FYI by slittle · · Score: 1
      This is not completely true. When you add some swap to your systems you will find that there is some margin where it will use the swap but not slowdown. This is because some processes allocate memory that they later (almost) never touch. This will be swapped out, and your RAM will be used for better things.
      More of an issue on servers than workstations I would think, where you have more stuff sitting around idle waiting for something to happen. I tend not to run things I'm not going to use.

      But my 1GB RAM system has 100MB of swapspace in use, and I have not run any very-large applications in the 41 days it is up.
      Of course, but that doesn't mean the used swap is actually needed though. Right now I have 700MB of disk cache - it wouldn't matter much to me if adding swap made that 800MB instead. What would matter is if I did some heavy IO tasks, like copying around a few ISO images, that made it swap everything out to boost the cache, and afterwards I have to wait for it to swap everything back in. Turning swap off (or tuning it to not swap unless absolutely necessary) would stop that.
      --
      Opportunity knocks. Karma hunts you down.
  60. No more swap! by ChiralSoftware · · Score: 1
    I admit that I don't fully understand all the issues of swap, but here are some observations:
    • Generational garbage collectors, such as the one used in the JVM, screw up swap. It seems like there is a conflict between what the OS is trying to do with swap and what the JVM is trying to do with GC. I would rather let the GC win in this so the application runs fast.
    • Memory is cheap these days. I just started up OpenOffice, widely regarded as a hog of a process, and it takes 27mb. Huge, you say? That's about $2 worth of memory these days.
    • Does swap actually make things faster? The concensus these days seems to be "if your process is swapping you need more memory." Therefore... why swap?
    It seems like the place where swap makes sense is that you can have a bunch of non-running/idle processes all "running" at the same time, while swapped out. I'm not sure how much this is needed on modern machines with > 1gb of ram.

    ----------
    WAP software

    1. Re:No more swap! by egomaniac · · Score: 2, Interesting

      Generational garbage collectors, such as the one used in the JVM, screw up swap. It seems like there is a conflict between what the OS is trying to do with swap and what the JVM is trying to do with GC. I would rather let the GC win in this so the application runs fast.

      You are absolutely correct that garbage collectors play hell with swap. It's pretty easy to understand why: to determine what is garbage and what is not, the garbage collector has to check every live object and see what they hold pointers to.

      Think about that one for a sec -- the garbage collector has to look at every single live object on the heap during every garbage collection pass. This means that any pages which were swapped out have to be fetched from disk, so you end up (usually) loading the entire heap back into memory during garbage collection.

      The aforementioned problem is true of all accurate garbage collectors. The other problem depends on the exact sort of garbage collector, but in general live objects are moved around in order to clean up holes in the heap (think of it like compacting a database). This can give you another "scan the entire heap" situation.

      The only real exception to this rule is that large data structures (such as the pixel data for an images) that do not contain pointers and thus do not have to be examined can remain swapped out if they aren't relocated during a particular garbage collection pass. The first page of the data structure must always be loaded no matter what, hence the "large" (really, multi-paged) disclaimer.

      An OS based on a GCed language such as Java will probably have to come up with some really innovative tricks for managing swap, or just do without.

      --
      ZFS: because love is never having to say fsck
    2. Re:No more swap! by Unknown+Lamer · · Score: 2, Interesting

      A generational garbage collector does not always have to check every single live object. It allocates objects in different generations (e.g. a generation may be every 5M of memory allocated by the GC) and the newest generation is scanned first and older generations are only scanned if memory cannot be found in the nearer generations.

      This (mostly) alleviates the problem with straining swap because the GC is mostly scanning recently allocated memory that is probably still resident.

      --

      HAL 7000, fewer features than the HAL 9000, but just as homicidal!
  61. What are you doing with your system? by Anonymous Coward · · Score: 1, Insightful
    If your system is being used as a desktop, and responsiveness isn't an issue, and you have enough memory for everything you need/want to do -- great. Don't worry about swap. However... for servers, in particular, running without swap is not a good idea. Several reasons:
    1. The system can swap out unused portions of memory (that have been allocated, written to once, and not touched in a long time), and use that memory as a disk cache. Depending on how often those "unused" portions are needed, this can be a big win.
    2. As somebody else pointed out, if a process goes haywire and allocates far too much RAM, swap gives you a bit more breathing space before it becomes a problem.
    3. Final point. Under Solaris, you can configure the kernel so that, if it panics, it dumps the entire contents of RAM to the swap partition. On the next bootup, this memory dump is read, and put into a real file on a real filesystem. This can help track down the cause of problems. But for this to work, the swap partition must be at least as large as the amount of physical RAM you have.
    Why write the contents of RAM to swap? Well, where else can it go? The kernel's just had a panic. You can't trust any significant part of the code (eg: filesystem drivers). You do, however, know where the swap partition is, and it's safe to scribble all over it; none of the apps that were running are going to continue anyway.

    It's all about what you want to do with the system, and making a judgement call on this. Me? I say, disk is cheap; why not have a swap partition?

  62. One of the tricks.. by Sir+Pallas · · Score: 2, Interesting

    ..that I think is spiffy is using the partition I would normally use for /tmp as . Then, I mount a tmpfs of that size on /tmp. This makes a large performance improvement for anything that uses a lot of temp space, because everything /tmp would normally handle is done in RAM until RAM fills up, at which point we're back to using the disk.

  63. Swap ain't the issue by erikharrison · · Score: 3, Insightful

    For the kinds of complaints about Linux swap I've been seeing of late, it would be bogus to call swap the issue, really. People looking to eliminate swap entirely on desktop machines are cutting off the arm for the sake of a finger.

    The issue with swapping in a desktop system is that perception of system responsiveness is almost as important as real performance, and swapping in (actually, it's paging in, but that's semantics) causes high latecy. This is especially noticeable when returning to an idle machine. So we want to cut latency.

    People say "the kernel shouldn't swap unless it can't fit everything it needs in system memory." Duh! And it doesn't! It's swapping to increase the size of the file cache, a huge performance win. If the file cache gets too small (say, because this Wal-Mart PC only has 128 megs of RAM, and you've turned off swap, so Moz is eating it all) then you wind up with disk seeks for harddrive intensive applications, causing the same latency as swap.

    What's clear to me from these complaints is that the file cache isn't smart enough. People with lots of RAM want to cut down on all these disk reads - that's why they got gobs of RAM. (Ain't it funny that the same Linux heads who say that Linux makes a little machine fly also say that a desktop has no reason to have less than 512MB or 1GB of RAM). At the same time, smaller machines should still be supported, and even folks with gobs of RAM don't want to elimiate swap, otherwise disk bound apps suffer the same latency they're trying to eliminate.

    The Linux file cache seems too aggressive for most users. Ext2 loves a file cache like no other filesystem, and this probably influenced the design. If the file cache can be smarter about when to swap to grow itself, and when it should just be content to use up all available system memory, then lots of these latency issues can be fixed in a way which will scale across both hardware and multiple use environments.

  64. Swap can be added on-the-fly; memory can't. by Anonymous Coward · · Score: 0

    To add memory to a server you must take it down. This is bad for uptime figures.

    If the peak loads on a machine are starting to hit triggers then you schedule and outage but if the client load surges then you can add a swap file on-the-fly as a temporary fix to get the server through to its maintenance window. Sort of a limp-home mode.

    Then when its maintenance time the machine can be tweaked based on its new peak load.

  65. No by Anonymous Coward · · Score: 0

    Swap is not necessary.

  66. Possible solution... by fprog · · Score: 0

    Why not simply assign a MAXIMUM amount of RAM
    that normal application may used,
    let say an application may never used more than 64 MB of RAM.

    Application like OpenOffice, Mozilla, GCC, KDE, GNOME,
    could be

    nice --RAM 512MB pid
    nice --RAM 0 pid = No limit

    or started with a shell script with a specific amount of RAM.

    If an application runs out of RAM, two possible solutions:
    - Kill it "gracefully"
    - Suspend it and send an email to root@host
    basically, you reduce the timeslice to 0.

    This would allow for instance "nuclear reactor"
    to have that process use whatever it needs
    and watchdog or any other "less important"
    process get killed, instead of having
    the entire system becoming slugish
    after some amount of time.

    You may also provide a 'hint' to the parent process
    via some API that the child got "out of control"
    and something should be done about it.

    This would allow finer control over the current "statue quo".

    Just a tought.

  67. I suspect this is true by Solandri · · Score: 1
    Try shutting down a big app that takes a while to unload (Mozilla works). While it's shutting down, try to start another instance of the same app. Windows will show the hourglass pointer as if it were starting another instance of the app, but it won't start. You have to wait for the first instance to finish unloading before XP will let you open it up again. If you try the same thing but opening up a different app, it works like you'd expect - the second app starts while the first one is exiting.

    It's as if rather than truly unloading the app from memory, Windows is just decrementing a flag which says the app is no longer in memory. When it decrements it to 0, it probably runs some routine which restores the used memory to the state it'd be in if you'd just started the app. But until it finishes this, it can't increment the flag to 1 (restart the app). Whereas if it were truly reloading the app at a different memory address, it could start loading it immediately.

    Given some of the behavior I've seen from users, I can actually understand making the GUI behave this way. I've seen many users who still don't get or refuse to use the concept of having multiple documents open at once. If they need to open a different Word file, they will exit Word (to close the file they're working on), then double-click on the new file they want to open. Restarting an app behind the scenes in this situation makes sense in a predictive branching sort of way.

    1. Re:I suspect this is true by BandwidthHog · · Score: 1

      I've seen many users who still don't get or refuse to use the concept of having multiple documents open at once. If they need to open a different Word file, they will exit Word (to close the file they're working on), then double-click on the new file they want to open.

      I think they're bludgeoned into that behavior by the use of MDI windows.

      I (not me, but some hypothetical user for whom Windows == Computing) double click a document, and the app launches then opens said document. When I close the document, I'm left with a useless gray background of the 'empty' app, rather than the file viewer I expected to see revealed underneath the app. So instead, I get into the habit of closing the app instead, as this makes things behave in a way that jives better with what I expect to happen upon closing a document. This habit then becomes ingrained.

      I (the real, non-hypothetical I who as an old-school Mac user is used to the paradigm of apps running yet having no open documents) find myself doing the same thing when searching through poorly named .DOC files at work. Even though I know better, it takes fewer mouse clicks to do it that way.

      On a semi-related tangent, ever notice how the typical Windows user (I resisted the temptation to put an L in front of that word) will needlessly start minimizing windows prior to launching an app from the Start menu? Weird.

      --

      Quantum materiae materietur marmota monax si marmota monax materiam possit materiari?
  68. Why not have it all in ram and still swap? by TechnoWeeniePas · · Score: 1

    There are thrid party cards out there that use standard dimms to make ram drives...woulnt the ultimate performance come from loading up one of these and putting your swap there? Then you would have the benifits of swap space but the speed of ram. That to me seems ideal.

    1. Re:Why not have it all in ram and still swap? by rfc1394 · · Score: 1

      Sooner or later someone will design an application that needs more memory than is physically present. Unless your machine is designed for that application to have enough to do everything in memory, sooner or later you will run out, unless you run a stable set of applications that all fit in the amount of memory available. Some systems, like databases, do the same thing as ramdisk virtual memory by establishing their own caches to store records retrieved to improve query performance. That sort of application is going to ask for as much real memory as it can get away with.

      --
      The lessons of history teach us - if they teach us anything - that nobody learns the lessons that history teaches us.
    2. Re:Why not have it all in ram and still swap? by TechnoWeeniePas · · Score: 1

      I think I didnt get my point across...or missread the reply...anyhow what I was talking about was PCI cards that used DIMMs to make a physical drive with RAM thus allowing a swap drive that is as fast (or close anyhow) to the speed of the memory rather than the speed of a hard drive. See cards such as the rocket drive for reference to what I mean.

  69. Re:swap sucks with 2k & xp - disable it if pos by BCoates · · Score: 1

    Do you have a deranged amount of disk fragmentation or something? What happens if you terminate the process (task manager->processes->executable name->end process->yes) instead of closing it normally?

    23 minutes to deallocate less than a gig of ram seems like you've got more serious problems than overly-aggressive swap behavior.

  70. Re: Is Swap Necessary? by Anonymous Coward · · Score: 0

    The general answer is yes. As always YMMV. However, the things have changed a LOT since all of the general "rules of thumb" came about. If you look back far enough (back around the late Cretaceous and please stop staring at that bone in my hair) an awful lot of research was done into VM performance. There are several equations from that period that you can use to characterize the performance of your VM system.

    Fast forward to present times... if you'll apply those very same equations, I think what you'll discover is that page sizes ARE WAY TOO SMALL for current processor, disc and RAM speeds. Today we should probably have pages about 64k or 128k in size given the relative performance of things. I'm too old & lazy (and it's too late) for me to look up the references, but for the more energetic and inquisitive among you, it wouldn't be too hard to track down (Sherman, set the wayback machine for the year 1979 (or there abouts)). Having been in the business for a while, it's curious to see how cyclic things are. That said, some applications (like HTPC) probably DON'T need swap (but still want a disc to store program material on).

    OK, just so this post isn't totally content free, the basic equations (for the ambitious) are based upon the cache equation (which, afterall, is what VM is). The cache equations is:

    T(a) = T(r)*P(r) + T(m)*P(m)

    The terms of the equation are:

    T(a) - time to access an item
    T(r) - access time if the item is resident
    P(r) - the probability that the item is resident
    T(m) - access time if it's not resident (miss time)
    P(m) - the probably that a miss will occur

    If you look at the access patterns of programs, generally if you increase the page size, the number of misses will go down (taken to the extreme, if the page size was the same size as large as the program, there obvious would be no misses). What we're seeing (as CPU and memory speeds go through the roof) is that the miss cost (T(m) - the time to access the backing store/disc) is (relatively) increasing. Increasing the page size will(or at least should) cause the overall cost of an access to decrease (assuming the other assumptions are correct). The rest is left as an exercise to the reader.

  71. Re:You guys will hate my laptop. by Anonymous Coward · · Score: 0

    hahahahaha.... you lose karma for being a jackass! take that jackass! maybe next time you'll be a little less of a jackass when you decide how big your swapfile is, hey jackass? you like that, don't ya jackass! jackass! jackass!

  72. The answer is simple by BigBuckHunter · · Score: 1

    The answer is simple

    The execution of the answer is not so simple

    It is good practice to establish a profile of the applications that you run (memory wise) and to then purchase adequet RAM to suit that application profile. Basically, figure out how much RAM you "normally" use, and then buy it (plus a bit extra). DB server profiles are as different from web server profiles as office profiles are from gaming profiles. Without the context the particular profile, blanket statements regarding memory and swap tuning are meaningless.

    Thank you for your time,

    BBH

  73. It is too by Anonymous Coward · · Score: 0

    I start a routine 3 GB compilation on my workstation with -j 6 and distcc. While I wait for it to finish in 20 minutes, I need to use the 3-GHz/1-GB PC to check my mail with KMail, perform some vmware MS-Access errands, and fill out some Web forms with Firefox. The CPU load is at 5, but one sixth of the machine should still be a 500-MHz PC, which ought to be more than enough for such human-pace activities.

    No such luck! The file access kicks all the applications out of RAM. Even the mouse barely moves. The window frames become unresponsive for seconds or longer.

    A few days ago I turned off swapping, and the machine has actually become usable during compiles. It still swaps out the text segments of the executables, which causes occasional delays and funny, unexpected keyboard autorepeats. To deal with that, I'm planning to move the desktop utilities to a ramdisk.

  74. Swapping on other Unix systems by PhunkySchtuff · · Score: 2, Informative

    IMHO Swap is a good idea and here's why.
    I admin Solaris systems, and swap on Solaris is a fine thing indeed.
    You allocate a complete slice of a hard disk for swap, and you can then add and remove swap dynamically while the system is running. Need 1 GB more swap? Create an empty 1GB file, and add it as swap.
    What's more /tmp is mounted on swap. If you, say, have 1GB of swap space and chuck 512MB of stuff in /tmp, you've now got 512MB of swap left. Lots of Unix software dumps stuff in /tmp and, when there is available RAM, /tmp lives in RAM. This makes temp files very fast.
    Plus, the VM subsystem also deals with the file cache so on a Solaris system, you will see the amount of RAM used always around the 100% mark. No point in having RAM there unused, it costs too much. Use it as disk cache.
    In addition, when an application needs to be swapped out to disk, why bother writing to disk something that's already there - the application's code is marked as being paged out to disk and removed from RAM and when it's needed again, the code is fetched from the original binary that the application was loaded from.
    All in all, these kind of modifications to the VM subsystem mean that swap is good to have and can make systems faster with it than without.
    k:.

  75. No swap by HermesHuang · · Score: 1

    I used to run a linux computer on 256 MB of RAM and no swap. Turned out it was a bad idea when playing with Gimp. I once tried to open a large image file which ended up taking on the order of 8 hours to load (I basically went to sleep and when I got back up it hadn't quite finished). From then on, I started implementing a swapfile. If nothing else, now I have swap as a "just-in-case" measure so that in case I have to deal with something extremely memory intensive the computer won't slow to a crawl. I tend to implement swap using a swapfile, though, so that I can change it more easily, and in some cases turn off swapping.

    1. Re:No swap by CAIMLAS · · Score: 1

      Huh. I've never seen that happen. Only thing I've seen happen when the system runs out of memory (in this case RAM + swap) was a hard freeze that sysreq didn't fix.

      I believe the same was the case -swap, though I could be mistaken.

      --
      ~/ssh slashdot.org ssh: connect to host slashdot.org port 22: too many beers
  76. Not always needed by mcbridematt · · Score: 1

    I ran my system without swap for a while. I never really needed swap until I tried playing UT2003. At the time it only had 256MB of RAM and I had been running 2.6.0-testX kernels.

  77. Swap thrashing is a symptom, not a cause by majid · · Score: 4, Insightful

    A swapless system won't be faster for the same workload, usually the contrary, in fact, since lack of swap denies the system the opportunity to optimize RAM hit ratios. What a swapless system can do is force admission control on new processes in the system, thus enforcing a no-overcommit policy on RAM, and therefore increasing responsiveness at the expense of global throughput.

    Swap thrashing in a desktop environment is usually the sign of a workload that is too high for available memory, e.g. trying to run far too many apps simultaneously. No amount of OS smarts is going to compensate for overbooking RAM with too large a working set. The solution is to increase RAM or not run as many apps simultaneously.

    Swap thrashing in a server environment is usually the sign of improper server configuration. Naive administrators configure too many processes, thinking they will avoid a bottleneck if all server processes are busy, but all they achieve is turning RAM into the bottleneck rather than the server processes themselves. If you have a web server and configure Apache to have too many running processes, these processes will spend their time contending for RAM instead of doing useful work. Too many cooks spoil the broth. A swapless system would prevent excessive Apache processes from starting in the first place, thus alleviating the problem (at the expense of high error rates, which is probably not acceptable), but performance won't be anywhere as good as a system with swap and properly sized Apache process limits.

    Swap is not a panacea. It should not be used to protect against runaway processes (setrlimit is here for that). It is useful in absorbing sporadic spikes in traffic without causing denial of service, and to shunt away uselessly allocated virtual memory (ahem, memory leaks).

    As for the idea of putting swap on a RAMdisk, it is completely brain-dead (unless you have exotic memory arrangements such as NUMA) - the kernel is going to waste a lot of time copying memory from the active region to the ramdisk region and back. A straight swapless system will be preferable.

    There is no hard and fast rule for sizing swap, it depends on your workload, such as the average ratio of RSS to SIZE. The usual rule of thumb is between 1x and 2x main memory.

    1. Re:Swap thrashing is a symptom, not a cause by rfc1394 · · Score: 2, Interesting
      A swapless system won't be faster for the same workload, usually the contrary, in fact, since lack of swap denies the system the opportunity to optimize RAM hit ratios.
      Agreed. This is the real reason to have swap space, so you can run more applications than you have resources for. It also allows running applications to push ones that are not doing much out of the way while they are stalled (waiting for a resource) or otherwise not running (a process like, say, a database server that is sleeping until it gets a record or SQL request) and thus not use resources while not operating.
      As for the idea of putting swap on a RAMdisk, it is completely brain-dead (unless you have exotic memory arrangements such as NUMA) - the kernel is going to waste a lot of time copying memory from the active region to the ramdisk region and back. A straight swapless system will be preferable.
      On this I am going to have to disagree with you. If you have some swap, the system can move least-used pages out of the way as it runs out of primary memory or as it notices rarely-running processes that can be shunted off to release primary memory to processes that are running. Disabling swap altogether means that the system has to run out of resources, attempt to swap them out, discover it has no swap, then kill something or refuse to honor a request for more resources to make room. With swap, even if it's to a ramdisk, the system can remove processes at the high-water mark and if the hits aren't too high, it is conceivable that better performance might occur over a system that simply has no alternative but to hit the hard limit and run out of resources as opposed to crossing a soft limit and not ending up in a starvation condition.

      Under normal circumstances it would make sense that having all available memory would make more resources available than stealing some to make a virtual memory swap space, but as most operating sytems are designed to swap pages out as they are unneeded or when processes start to hit the high-water mark, the overhead of the swap manager running and being unable to do anything due to no swap at all just might be higher than the small amount of time needed to do some unnecessary copying of memory to swap out some rarely-used pages.

      Short of someone running a test on a machine with no swap at all vs. say a tiny amount of ram used as a ramdisk (say 5 meg on a 1 GB machine) it's probably an academic argument to say flat out that no swap will always provide better peformance than swap to ramdisk, especially if the kernel is designed to expect to be able to have swap around.

      If the kernel is designed to only swap out on resource shortages and not to optimize running processes as well, then swap to Ramdisk is a brain-dead operation. But I suspect the actual method of operation is a little more complicated than mere copy-on-resource-shortage, and thus it is conceivable that swap-to-ramdisk may provide better performance than no swap at all.

      Paul Robinson <Postmaster@paul.washington.dc.us>
      --
      The lessons of history teach us - if they teach us anything - that nobody learns the lessons that history teaches us.
    2. Re:Swap thrashing is a symptom, not a cause by mindstrm · · Score: 1

      That seems absurd.

      The overhead of the swap manager running with nowhere to swap? That's a big assumption... disabling swap does not slow down the machine because it needs to swap...

      You will hit a hard limit just about as fast.. with the speed of swap ramdisk.

      Instead of 1GB of physical, you have 768MB phys and 384MB of SWAP in RAMDISK.. you STILL have the same amount o f VM.. 1 GB.

      It will just be slower accessing that last 384MB of swap in the ramdisk scenario, degrading performance.

      That's 384MB you COULD have had for disk caching, otherwise.

      SWAP provides better performance only when increased ram for disk caching increases performance.. freeing up unused pages to be used for cache, in other words, which you cannot do without swap. Provided the disk caching is adequate already, with enough free memory, wasing cycles and resources to swap out memory to disk is never going to be FASTER than simply using enough physical memory to begin with.

      All it will do is slow you down.

  78. Swap, RAM, should behave as processor caches by Framboise · · Score: 1

    Actually swap is just an another level of caching. Ideally swap space should behave as other caches at other levels, and just be made of the free unused disk space, or a good part of it. This is the optimal way to use ressources as found over the years at the processor level, and at the RAM level. One should not specify the amount of swap space, the sytem should be able to use whatever free disk space is left.

  79. One size does not fit all by Alain+Williams · · Score: 1

    Above there are many arguments/illustrations for one or the other. Linux is used in a very wide variety of systems - to meet different technical and budget criteria, some will need swap, some won't.

    You have the choice - configure according to your needs.

  80. Piggin says swap = good. Even if swap = ramdrive? by jago25_98 · · Score: 1

    "Nick Piggin [interview] explained that swap can improve performance no matter how much RAM you have, "well it is a magical property of swap space, because extra RAM doesn't allow you to replace unused memory with often used memory. The theory holds true no matter how much RAM you have. Swap can improve performance. It can be trivially demonstrated." This said, numerous Linux users do report success running a swapless system."

    ^ so you're saying that having say, 512mb mounted as swap on a ramdrive and 512mb normal ram is better than just all ram?

  81. Reasons for swap... by emil · · Score: 4, Interesting

    I don't know if Linux works this way, but...

    1. The mmap() system call, which allows you to treat a file as an area of memory and manipulate it with pointers in C, oftentimes copies (portions of) the file into swap.
    2. Many systems, when you execute a binary obtained over NFS, will cache the binary in swap in hopes of preventing further transfers over the network.

    UNIX kernels have assumed the availability of swap for nearly 35 years. You cannot remove this major architecutural feature without unintended side effects.

    1. Re:Reasons for swap... by Anonymous Coward · · Score: 1, Informative
      The mmap() system call, which allows you to treat a file as an area of memory and manipulate it with pointers in C, oftentimes copies (portions of) the file into swap.

      Most commercial Unix systems have had a fully unified memory architecture for a while now; I'd say something like 10 years. Pages of executables and pages of mmap()ed files work the same way: the memory manager just maps them to a virtual address and faults them in and out as necessary. That is to say, the memory for an mmap() file is not loaded into RAM then copied (partially) to swap. Instead, the virtual memory is just backed by the mmap()ed file itself. Even if low memory forces you to evict all the pages of the mmap()ed file, no swap is needed to do this, because they are flushed directly back to the original file itself.

      Likewise with binaries: in the old days, you would execute a binary, and this would cause the loader to copy the entire binary into virtual memory, possibly putting some of it on swap. But on modern Unix systems, loading a binary means simply mapping the virtual memory address space directly to pages in the executable's file (at least for the read-only portions of the executable, which are the majority). This has the advantage that if a part of the executable is never run, it's never even loaded from disk. It also means swap space is not needed used, and no copying is done. It also means that two processes can share the *same* page of the executable; even if they are two different users, they can still be executing out of the same page of physical memory because the code is read-only. (Of course, this only applies to the read-only pages of an executable, and not all of them are read-only. But the ones that aren't mostly equate to variables declared in a program and obviously those can't be stored back in the executable in the event of low memory...)

      Many systems, when you execute a binary obtained over NFS, will cache the binary in swap in hopes of preventing further transfers over the network.

      This, on the other hand, is possible. I don't have any personal knowledge of any OS that does that, but it could be done, and the unified virtual memory model I mentioned above wouldn't be able to help (in contrast to the fact that it can help with locally-backed executables).

  82. Gaming without swap, with 512MB RAM (or less) by grolschie · · Score: 1

    I have an XP 1800+ with 512MB on Win98SE. Disabled swap. Noticable performance increase. Cranked up a game of RTCW Enemy Territory, completely one map with great performance!!! Game crapped out when trying to load the second map and froze, not enough (i.e. zero) swap dag nabbit. Needs more RAMses I do.

  83. Turn all your hard disk space into swap! by TheWoundedSeagull · · Score: 1


    Turn all you disk space into swap space and do everything in memory!

    RAM versus Hard disk...

    Virtual memory is one concept to free the programer from having to think about physical program size versus physical memory size, by providing a general mechanism to get stuff to and from the hard disk into physical memory.

    Files/file systems are another concept, that also require the loading from hard disk to and from physical memory (ultimately).

    Who needs both!

    Transactions? What? yeah, yeah, yeah... Your happy to do all the file open, file close, read, read, read, but not prepared to be explicit about transaction boundaries? *sigh* use method invocation and pay the penalty, chump.

  84. Actually... by warrax_666 · · Score: 1
    It doesn't improve performance,

    Although it may sound counterintuitive, it can (and usually does, unless you have obscene amounts of RAM) actually improve performance. Here's why: If the computer can swap something out which hasn't been used in a long time, you can use the freed physical RAM for other things, e.g. more disk cache, thus speeding things up.
    --
    HAND.
    1. Re:Actually... by Jeremy+Erwin · · Score: 1

      Although it may sound counterintuitive, it can (and usually does, unless you have obscene amounts of RAM) actually improve performance.

      Which begs the question: How much RAM constitutes an obscene amount? And if your RAM complement is obscene, won't the overhead of swapping cut into your performance?

      (I use MacOSX, which eats RAM quite greedily-- but it's still difficult to use more than my current complement of 768 MB. When I do, it's very noticeable.

    2. Re:Actually... by Kynde · · Score: 1

      >> Although it may sound counterintuitive, it can (and usually does, unless you have obscene amounts of RAM) actually improve performance.

      > Which begs the question: How much RAM constitutes an obscene amount? And if your RAM complement is obscene, won't the overhead of swapping cut into your performance?


      You're not getting it, are you. Obscene is naturally the normal RAM you need to run your apps plus the same amount as your hd, because at that point you can cache everything and swapping even the totally unused pages will not result in performance boosts.

      The point is that even if you have few gigs RAM even in those cases it makes sense to swap out some pages that haven't been used for a long time. Because that always yields more free memory to be used as page cache.

      What the confusion here is mostly about is that people mix page evictions with swap-outs.

      --
      1 Earth is warming, 2 It's us, 3 it's royally bad, 4 we need to take action NOW
  85. Why use swap? by Anonymous Coward · · Score: 0

    ...because I *CAN*, you insensitive clod!

  86. Stupid developerssssss!!! by Anonymous Coward · · Score: 1, Informative
    I want a cheap supercomputerserver of 64 bits:
    Opteron-144 with 4 GiB of RAM ECC (4x1GiB) and 80 GiB of swap (RAMx20) ATA133.
    Is ready the kswapd of x86-64's long-mode?
    No, kswapd is for 32 bits :( (upto 2 GiB per process), i'm waiting for 64 bits (upto more than 4 GiB per process).

    open4free ©

  87. Don't run applications written in Java! by Tim+Ward · · Score: 1

    Then you won't have anything using hundreds or thousands of megabytes in a pathological fashion for a tiny little GUI and you don't need to worry about lack of memory on a modern machine.

  88. Swap necessary by pjc50 · · Score: 1

    If you want to run a program bigger than your available RAM, then you need swap.

    The software I'm developing uses about 3Gb, most of our systems have 2 ...

  89. Re:Piggin says swap = good. Even if swap = ramdriv by tilk · · Score: 1

    Not true. He's saying, that adding swap to system with some RAM can improve performance. So, 512 MB RAM + swap can be faster than 512 MB RAM without swap. But 1 GB will always be better than 512 MB RAM, regardless of having swap or not.

  90. Memory priority? by MuMart · · Score: 1
    Do higher scheduling-priority processes have higher priority on the ram as well? I think something like this would solve many of the problems they were talking about.

    For example, an "interactive" task like a login could steal some hot pages from lower priority apps already running.

  91. Win or not? by warrax_666 · · Score: 1
    swapping to increase the size of the file cache, a huge performance win.

    Well, the trouble with this is that there are rapidly diminishing returns on the size of the disk cache. At some point it becomes pointless to swap to try to increase the size of the file cache.

    (However, being able to allocate more than the physical amount of memory and avoiding thrashing as long as the working set is smaller than physical RAM still counts for something if you normally work on huge data sets).
    --
    HAND.
  92. Peter Norton (Was Re:BillG and 640K) by rfc1394 · · Score: 1
    Bill Gates never made the infamous "640K... enough for anyone" comment. Not only have I never seen it documented anywhere, but he was asked about it and replied that he never said that.[ ] But people keep beating him up about this bogus quote, and I'm tired of it.
    I think it was actually Peter Norton who said it, but somehow it got attributed to Gates. I know Norton said something like that (he may have said "256K" actually) because I remember reading it in one of his books. Of course, this was when DOS was the only game in town, but...
    --
    The lessons of history teach us - if they teach us anything - that nobody learns the lessons that history teaches us.
  93. Swap Partitions by HeghmoH · · Score: 2, Interesting

    I haven't touched Linux for several years, although I used to do serious work on it.

    I take it from the tone of the discussion that Linux still uses separate swap partitions? Why? My main machine now runs OS X, which swaps into the filesystem, and that seems to work a lot better. The system can decide what it needs to use, and I don't have to make a decision. I recall that Linux supports swap to the filesystem, but it sounds like nobody actually uses this feature. I can somewhat understand a server using a swap partition, since the needs of a server would be more or less known in advance and I assume it's marginally faster, but I don't see any reason to use one on a desktop machine. Why is everybody still using dedicated swap partitions?

    --
    Mod down posts with a "Free Mac Mini/iPod" sig, they're spam!
    1. Re:Swap Partitions by Corydon76 · · Score: 4, Informative
      Because until relatively recently, Linux used a very slow filesystem by default: ext2fs. This is, for example, why ext2 filesystems are always mounted asynchronously, as attempting to wait for each disk operation to sync would slow down the system dramatically. You'd have to be concerned with swap not going to disk immediately (just moving into disk cache, waiting to be synced to disk, which can take up to 30 seconds!).

      Now with more advanced filesystems that can be mounted synchronously, using a swapfile is less of a problem -- it certainly could be done, but you still get a performance hit by having to manage a filesystem entry, rather than swapping to raw disk.

      BTW, a number of databases use raw disk for exactly this reason -- to avoid the performance hit of managing a filesystem. And yes, it will make a difference to the overall performance of your database.

  94. Re:swap sucks with 2k & xp - disable it if pos by WuphonsReach · · Score: 1

    23 minutes to deallocate less than a gig of ram seems like you've got more serious problems than overly-aggressive swap behavior.

    Definitely agree with that assessment. NBPro might be a pig, but the parent poster's machine needs some serious work if de-allocating memory takes 20+ minutes. While I've seen it happen, it's only when you exceed the amount of physical memory in the machine by a goodish amount.

    The parent poster should've used 1 spindle for O/S and applications. With the 2nd spindle dedicated to swap, temp and data files.

    --
    Wolde you bothe eate your cake, and have your cake?
  95. We don't need no steenking swap... by ricky-road-flats · · Score: 1
    I don't see the need for swap any more. It's *so* much slower than RAM, even with U320 RAID arrays, and unnecessarily thrashes the disks when they could be doing more useful things or just 'resting'. I have two main machines, a laptop and a desktop. They both have 1GB of RAM and no swap - in Linux (Gentoo) and in Windows XP. With these setups, I have never, repeat *never* had a problem running out of RAM. I set them up like this after spending a year with 512 MB RAM and 512 MB swap in each - and as I'd never run out of swap then, I figured a GB of RAM would be better. It is.

    My dekstop hasn't been rebooted in a couple of weeks, and I've had a couple of sessions of Far Cry each day, Azureus running the whole time, watched a couple of DVDs, used Outlook, Zircon, Nero, Celestia and quite a few other apps. Task Manager tells me I haven't been over 840 MB used. If/when apps and games push it over 1GB, RAM is cheap and both machines can take 2 GB.

    At work, I make sure the servers I build are specced with enough RAM for the job (Windows Server 2003, SQL Server and IIS mainly). When first installed, I give them 1 GB of swap and then do protracted burn-in tests including unfeasably high test loads. Generally tehy don't go above the RAM they have, and once I've proved it I turn off the swap. If they run out of RAM, we get more RAM. We now have a few on 4 GB and 8 GB, so those 64-bit extensions are coming at an ideal time!

    In summary, RAM is fast and cheap enough, disk is slow and mechanically vunerable to failure. Don't swap!

  96. Riddle me this by Spackler · · Score: 1

    Ok, I have a responsiveness question on this subject. This annoyance has gotten worse over the years.

    Install a RedHat AS 3.0 system, using generic settings (normal amounts of swap and such. Log into X and open up a terminal session. Run "free" in that terminal.

    Start any other program you want, and it will probably start pretty quick. (time it)

    Reboot, and open up the same terminal session and run free again.

    Walk away from the system and come back the next day.

    Walk up to it, and run free in that exact same terminal.

    What you will see is that most of the memory is now used (I'm assuming it is the active disk cache).

    Now, start the same app you started yesterday after running free

    It will take at least twice as long to start (probably more).

    You can write a quick program that will use all the memory in the machine (huge perl array or something). This will free all the memory, and starting other apps will be fast again, until the system sits idle for a while.

    I have done this with different versions, and different systems, but the results are always the same. A system sitting idle uses up all the resources.

    Now, my question. How the heck are people getting months of uptime when the performance appears so bad just sitting overnight? Also, how the heck do you stop this, and why is it designed to be so hyperactive when sitting idle? This is one of my biggest frustrations in linux, because the responsiveness goes to poop all the time (performance is poop as well).

    1. Re:Riddle me this by pe1chl · · Score: 1

      The answer to that is: it may get worse overnight, but it does not get worse and worse from that.
      The first night it will run updatedb and possibly other scripts that fill the disk cache, but it is not a memory leak or something else that claims more and more memory.

      In fact on one server at work I do run a program that claims all memory and frees it, early in the morning after all those jobs have run. This improves things when memory is a bit short.

  97. Disk cache. by OgGreeb · · Score: 1
    I believe the problem is a contradiction in purposes. The disk cache confuses the original question. The argument is that more, but unused RAM is wasteful, so we have the OS take the unused RAM and fill it with a disk cache. But then we are out of available memory, so we have to have swap to provide for graceful memory handling. What would be the case for performance if we:
    1. Take a system with X RAM and swap.
    2. Add Y (=X) more of RAM,
    3. Disable swap, and
    4. Limit the maximum disk cache to available space in the original X amount of RAM.
    Wouldn't that enhance performance over a system with X RAM and swap?
    --
    -- Gary Goldberg KA3ZYW 301/249-6501 AIM:OgGreeb Digital Marketing Inc., Bowie, MD //www.digimark.net/
    1. Re:Disk cache. by Rich0 · · Score: 1

      A system with X RAM + Y swap will always be slower than the same system with X+Y RAM and no swap.

      Right now I have 512MB of RAM and 5GB of swap (love 64 bit - hard drive space is cheap...). There is no question that I'd have better performance if I just went out and bought an extra 5GB of RAM. But that would cost hundreds of dollars. My 5GB of hard drive space costs about $3 or so. So now, the question is whether a 200 fold increase in cost is worth the performance gain? For that much I could have gotten a dual-processor system instead...

      As far as limiting cache goes - why? If you add Y RAM and disable swap, just leave the cache alone. If you have 100MB of RAM not used for anything why not just use it to cache files? If the RAM is needed the computer should dump the cache as needed.

      Swap is the poor man's solution to more RAM. And there is nothing wrong with being cheap - it means being efficient. If you want longhorn to go fast I'm sure that a virtual P4 emulated by a cluster of 1024 AMD64's with 64TB of RAM would do a great job. But I have better uses for my basement and the local hydroelectric dam.

      Swapping is about putting cheap memory (disk) to good use, and using fast memory only as much as necessary...

  98. Slow I/O should not be cached indefinitely by swilver · · Score: 2, Interesting
    I have a Windows XP and a Linux box (2.6.4 kernel), both with 1 GB and both running without swap. The reason for this is simple; when I have my systems running a while doing nothing but serving files (slow downloads, or simply watching a big 2 hour movie), the machines will both be totally unresponsive when I get back to get some real work done; literally everyhing needs to be swapped back in because the machines use like 800 MB of it for cache buffers.

    Both OS's have filled their RAM with completely useless cached files (part of a 1 GB+ AVI for example, that I will most likely not be watching again for several months), swapping out all the programs I have running.

    Both OS's really need to learn how to deal with Slow I/O. If I/O is only being done at a rate that is a fraction of my harddisk speed (say 300-400 kB/sec), which occurs for stuff like watching a movie, playing music, serving an upload over DSL, then this data is really not worth caching for longer than a few minutes. Even if I do need it again, it will probably again be at just 300-400 kB/sec, something a harddisk can take care of quite comfortably.

    --Swilver

  99. Winning with intelligent RAM drives? by SlowGenius · · Score: 1

    I know this wouldn't solve everybody's problems, but: it seems like what's really needed by most people is the ability to easily place critical apps and/or data files into a reserved area of working memory that never gets swapped or paged out. I think this would differ from a run-of-the-mill RAM drive in that (I think) RAM drives aren't really part of 'working' memory, so apps/data stored in them still need to be loaded/paged/swapped in to be active. This all seems like such a pathetically obvious idea that I'm really expecting somebody in the know to say, "Duh... to do this, you just _________". Any takers?

    --
    Listen to what I say, not what I mean...
  100. Conflicts by Bluelive · · Score: 1

    I think the problem is that application ram, file cache and mmapped files all content for the same pages. If we give these groups there own page groups this will be reduced alot. The os could shift the sises around a bit to minimise the amount of pagefaults it detects. The most common problem i see is that after i do something file intensive, other applications are horribly degraded, i suspect this is because mmap is pushing everything else to the swap file, which would only make sense if the the application is long running. But most applications i use that cause this arent long running, movieplayer, mp3s, file sharing, basicly anything multimedia. Maybe providing a bit more metadata on the kind of operations a binary does would help.

  101. This is easy enough by Anonymous Coward · · Score: 0

    Just allow people to set a limit on how much memory can be used by various things.

    So that instead of being flexible the things are hard coded...

    --

    IE, you have 1GB of RAM.

    You set aside 100MB as disk cache.

    This leaves 900MB for executables to run in.

    --

    The limitation of this is that it is not flexible and is fragile, if you need even 1 more byte above the 900MB you won't get it. Not even if there are 50MB that haven't even been touched yet.

    But many people are coming back with, we don't care, Linux is blazingly fast upto the point that something reads through all the files on the disk indexing them, which flushes every desktop application out to disk and then everything you click on for a few minutes takes seconds to come up the next morning.

    What people are saying is keep my programs in memory. They are even letting you assume that all the applications are well behaved. Because anyone setting this up is going to be able to fix it so they are well behaved.

    They are willing to sacrifice the trade offs involved and figure out the mix they need for a particular use all by themselves. They are saying, let my box run applications like it has 900MB of memory, but let it access files off the disk like a computer that only has 100MB of RAM.

    Creating swap space on a RAM drive is just one way they are thinking about how to reserve more memory in RAM for their processes.

  102. Photoshop...etc by Thaidog · · Score: 2, Interesting

    Any machine that deals with large files will still need swap space... Photoshop when dealing with large image files...etc

    --

    ||| I still can't believe Parkay's not butter.

    1. Re:Photoshop...etc by CdotZinger · · Score: 1

      Photoshop (or at least the versions I've used) has its own little swap implementation built in.

      On the box I'm using right now (old G4, OS 9), that's great. System-wide VM ruins the performance of the audio-recording and -processing stuff I run, so it's off. Photoshop is the only thing I use that needs swap--and can use it without puking and dying--and it takes care of it itself. Nice.

      --
      Your mouth is like Columbus Day.
  103. linux swap by oldwarez · · Score: 0

    Are there any tools for linux for reading/clearing swap files/partitions? And more importantly, how do you know if it is safe to clear/modify a swap?

    --
    username:oldwarez password:oldwarez
  104. My observations. by mindstrm · · Score: 1

    This could be incorrect, because I haven't actually sat down and figured out exactly what's happening, but, from my own experience, here's what I've found.

    If you run windows with adequate ram and no swap, it runs faster and smoother than the same setup with swap. Windows appears to push stuff into swap prematurely. example: 512MB of ram. ~200MB used. Windows is already swapping.

    Linux seems to not use swap until it damn near runs out of RAM. I therefore always put swap in linux boxes, for the simple reason that it's better to have performance start degrading but still work, rather than have everything ticking along just groovy and run out of memory.

    Swap *always* comes down to memory, one way or the other. If the system is not using all the ram, it can't really get any faster by using DISK instead of ram.

  105. nocache directive by Stephen+Samuel · · Score: 4, Interesting
    One of the errors that I see is Linux doesn't handle the read-once case very well.

    Once in a while I'll do something like 'grep -r "oops" /big/filetree'. The fact of the matter is that I'm probably only reading any of that data ONCE, and it's not going to all fit in memory anyways, so I don't even gain anything if I run the grep a second time.

    In a situation like that, I'd like to have some sort of 'nocache' directive that says 'Don't waste the cache with this'.

    Something else that might help would be to have some sort of 'minprog' directive which would tell the swapper that a certain amount of space is reserved for 'program' data (i.e. code (including shared libs) and data), -- and that that memory shouldn't be swapped out in favour of something otherwise being read from disk. I think that this might avoid the situation that I sometimes run into of a large program (mozilla/gimp) being unresponsive after I do some other disk-intensive task (like the aformentioned recursive grep).
    Things like the OS enforcing things like the RSS rlimit hints would also help. (I hadn't previously realized that it didn't).

    --
    Free Software: Like love, it grows best when given away.
  106. How naive can you get? by Anonymous Coward · · Score: 0
    Bill Gates never made the infamous "640K... enough for anyone" comment ... he was asked about it and replied that he never said that.


    And of course, he always tells the truth?

    1. Re:How naive can you get? by Anonymous Coward · · Score: 0
      Can you come up with an example where he flat-out lied? He is prone to feel-good marketing speak now and then (OS/2 is the operating system of the future), but I can't think of a time when he personally lied.

      Plus, he has admitted to being stupid before (e.g., he admitted to not knowing/caring about the Internet until the early-to-mid 90s).

      If you can come up with a single example where Bill Gates has lied about something, I'll admit I'm naive.

  107. My experience by jmichaelg · · Score: 4, Interesting
    My first job as a sysadmin was on a Burroughs 7700. My employer sent me to a week long class on tuning the os to help the company deliver a turnkey app that met some performance specs. Didn't matter what I did to the working set/swap settings - the thing was pig slow. The older guys in the class who had admin experience on IBM 370's were constantly complaining that the Burroughs OS was doing a worse job deciding how to allocate RAM than they could and it was making them look bad because the boxes wouldn't deliver the throughput they had had with supposedly inferior IBM hardware. As you can imagine, it was a very contentious class.

    My boss started worrying that we weren't going to be able to deliver what the company had contracted to deliver. He was the antithesis of a PHB and so he sat down and in a few hours wrote a small driver to emulate the overall task the project had to accomplish. No detail, just broad brush emulation. He was able to demonstrate with a few lines of code that nothing we could do would hit the delivery spec. Burroughs responded by doubling the amount of RAM on the box as well as installing RAM that was twice as fast as what they had initially delivered. The combination enabled us to turn off swapping and deliver a working product.

    Fast forward to 2004 and I'm working on Excel spreadsheets that have 60-70 sheets in a workbook. Saving the book is a bitch - 15-20 second wait after I hit ctrl-S. Every so often, Excel just goes away as it performs a prophylactic background save just in case Excel dies. 15-20 second pauses because the software has become so bloated that saving a 2-3 meg document is an excuse to flog the poor drive into a seek frenzy. The drive, which was about 4 years old, finally gave up the ghost. Its replacement has an 8 meg cache separate from the 512meg Windows manages - that "little" 8 meg junk of RAM belongs to hard drive alone. Night and day performance difference. The Excel swap frenzies that were induced by a simple ctrl-s are gone. 3 meg documents save in under a second - just what you'd expect from a drive that has a transfer speed in excess of 60 mbytes/sec.

    My sense is that swap has always been a kludge. It's an attempt to squeeze more data into a machine that has only so much space. The working set graphs look pretty but they seldom describe what is happening day to day. Trading 2 nanosecond response for a 5 millisecond seek is seldom going to be a good trade. Bottom line from that OS class 35 years ago? Keep your working set size less than your physical memory and your machine will remain responsive. Just what the old IBM Geezers were saying in the first place.

    1. Re:My experience by Anonymous Coward · · Score: 0

      Well, now, I started somewhat before the B7700, and when we used swap was when we needed to shovel more coal into the computer to get the CPU going again. Seriously, you use swap when it is more efficient to use a slower but larger resource rather than a faster but smaller resource that is limited. Us old IBM'ers knew when to swap the entire OS out of memory in order to get all (well, almost all) 32K words for a user program. Trading a 2ns for 5ms response may be just what is needed to increase overall throughput and get work done. It depends. Sounds like most of the posters never ran Unix on a 3MB VAX 11/730 with 24 users. Without swap it wouldn't have worked at all; with swap it worked well enough to do computation (4.1BSD, yeah). BTW, does anyone distinguish now between swap and VM page backing store? Nevermind.

  108. Ignored in this discussion: the swap algorithm by Anonymous Coward · · Score: 1, Informative

    This whole discussion has ignored the only important point.

    That's the algorithm for deciding which page to swap out. All systems I know of swap out the "least recently used" page when they need to swap something out.

    This is what causes the bad effects caused by swap. Suppose you (like me) have a machine that you use mostly as an X server. But naturally it's also running a few other servers, a MTA, an ntpd, minor stuff like that.

    You leave your desktop overnight and when you come back in the morning ... clicking on one of your X windows audibly causes a lot of disk reads and response is very slow.

    That's because your servers write to log files. Of course these writes stay in memory. And when Linux needs to swap something out (which it will do when a server writes to a log file), your X sessions get swapped out, not the useless logfile pages, because the logfile pages were used more recently. This is really braindead behavior. But that's how the swap algorithms, as currently specified, work.

  109. Steve Jobs said that by Skapare · · Score: 1

    Steve Jobs said that regarding the Lisa or whatever it was that came out before the Mac. He said that about 256k, I think when someone raised the issue that the new IBM PC could be expanded to 640k.

    --
    now we need to go OSS in diesel cars
  110. Agreed by Perianwyr+Stormcrow · · Score: 1

    RAM limits are a primary issue with machines I work on. These days I can't really do things 100% with less than 1G of memory.

    --

    What we call folk wisdom is often no more than a kind of expedient stupidity.-Edward Abbey

  111. So fix the cause, not the symptom ... by Skapare · · Score: 1

    So fix the cause, not the symptom ... don't use bloated programs.

    --
    now we need to go OSS in diesel cars
  112. Well this explains why Longhorn is late by craXORjack · · Score: 1

    Gates has to wait for the Linux engineers to finish innovating before he can steal their ideas.

    --
    Liberals call everyone Nazis yet they are the closest thing to it.
  113. i like swap by Flunitrazepam · · Score: 1

    I really enjoy swap space

    --
    1) Your analysis is based on bad assumptions so your result is way off. 2) You're a sick bastard for fucking a horse.
  114. segregation Re:No more swap! by WolfWithoutAClause · · Score: 3, Interesting
    The aforementioned problem is true of all accurate garbage collectors.

    Whilst that's strictly true, some modern languages use generational garbage collectors that segregate objects in memory according to age. Only when an age group gets full do they sweep through an age group, and move any surviving objects up to the next age group.

    This heuristic works exceptionally well, and runs fantastically quickly, and triggers significant swapping hardly ever.

    There are some circumstances where it runs slowly, but in the worst case the performance is similar to simply doing a full garbage collection. These situations are pretty rare; objects generally segregate very well into young/old or young/middle aged/old categories- the vast majority of objects die very young.

    Sad isn't it.

    --

    -WolfWithoutAClause

    "Gravity is only a theory, not a fact!"
  115. No: U R by Anonymous Coward · · Score: 0
    I haven't seen a case where disabling swap actually increases performance.

    Disabling swap will improve responsiveness not performance. And performance would only be lowered if the system had less RAM than needed for OS + apps + disk cache.

  116. Never put in more swap than you're willing to use by vlm · · Score: 1

    Never put in more swap than you're willing to use.

    It's "easy" with exploding disk sizes to give yourself several gigs of swap.

    However, transfer rates have NOT increased in proportion to disk size.

    Several years ago I could flood my 16 megs of swap in a few seconds to minutes. It would take "hours" to flood a couple gigs.

    For a good time make a graph of how long it takes to "read an entire hard drive" from the 80s to today. It's gone from reading the whole device in less than a minute to taking several hours in some cases.

    When you have a bug that allocates all your memory you will have to wait for the swap to flood full before the oom-killer will zap that process. A huge swap space makes a huge delay, may as well just reboot instead of waiting.

    Unless you have infinite patience I would not use suggest using more than a quarter gig or so of swap.

    --
    "Science flies us to the moon. Religion flies us into buildings." - Victor Stenger
  117. Similarly... by Anonymous Coward · · Score: 0

    The government doesn't 'tax' your income; they utilize it! ...tell me another one...

  118. Oh, my, isn't this fun... by NoOnesMessiah · · Score: 1

    As I read the KernelTrap thread I remembered having the same discussion with either Vernon Shriver or Mark Callow at SGI something like 14 YEARS AGO!!! The comment then was something like, "Bryan, there are only 4 people in the world, all of them in North America, and 3 of them are in mental institutions, that truely understand the strong juju that is swapping." That said, I have to wonder how many people posting on the swap thread have actually read the man pages, let alone understand swap and/or remember using xenix. Not only do they lack rough consensus and running code, they lack a fundamental understanding of why an operating system needs swap (do NOT equate M$s' virtual memeory with any modern unixes' swap), or, for that matter, most of them lack a fundamental understanding of operating systems. Leave your memory management to the system level codesmiths. If you want faster swap, buy a SCSI ramdisk widget and some ram and STFU. Your only other option is to earn a clue and start spending your nights and weekends becoming a tool builder. Otherwise, the "I want a pony" feature requests, critiques, and generally retarded banter from people who think they know something have every right to continue to fall on deaf ears.

    This thread is precisely why I don't contribute to those communities anymore.

  119. Use a swapfile instead of a partition by MarcQuadra · · Score: 3, Informative

    Use a swapfile instead of a partition. 2.6 kernels cache the location of the file, so there's no performance hit for swap files compared to swap partitions. I'll give a quick HOWTO:

    1. decide how much you want (you can change it later, I have 128MB on all my boxes with over 512MB RAM). The example uses 128MB

    2. #dd bs=1M count=128 if=/dev/zero of=/var/swap
    3. mkswap /var/swap
    4. edit /etc/fstab for: /var/swap none swap sw 0 0
    5. swapon -a
    6. There is no step six!

    But the best way to know how much swap you need is to peek at #top every now and then, or #cat /proc/meminfo and see how much you're using when you've got the system strained, use twice that amount, not less than 128MB.

    --
    "Sometimes, I think Trent just needs a cup of hot chocolate and a blankie." -Tori Amos on Nine Inch Nails
    1. Re:Use a swapfile instead of a partition by g1zmo · · Score: 1

      Honest questions:

      How are read/write permissions handled with such a swapfile?

      What happens if the root user does 'echo "I love swap space" > /var/swap' while that swapfile is mounted? Does the kernel allow this?

      Does 'cat /var/swap' dump a memory map of what's currently swapped out?

      Pardon my ignorace, but I've never known that Linux could utilize a swap file rather than a swap partition.

      --
      I have found there are just two ways to go.
      It all comes down to livin' fast or dyin' slow.
      -REK, Jr.
    2. Re:Use a swapfile instead of a partition by Rich0 · · Score: 1

      Disclaimer - I can't answer most of your questions. However, I'll hazard a guess to your question about overwriting the swap file - it probably borks the system.

      I'm sure if you run dd if=/dev/zero of=/dev/kmem or something like that it isn't good either...

    3. Re:Use a swapfile instead of a partition by ArsonSmith · · Score: 1

      mostly the same things that happen when you do those things to /dev/hda3 (or what ever device your swap partition is on).

      --
      Paying taxes to buy civilization is like paying a hooker to buy love.
    4. Re:Use a swapfile instead of a partition by MarcQuadra · · Score: 1

      My guesses for answers to your questions:

      How are read/write permissions handled with such a swapfile?

      Howerver you want, mine is root:root/700, but since the system itself is manipulating the file directly, I bet you could run it root:root/000 and it would work.

      What happens if the root user does 'echo "I love swap space" > /var/swap' while that swapfile is mounted? Does the kernel allow this?

      It would overwrite the file with a tiny file and would probably end up corrupting the filesystem of the drive, as the system would end up paging out to space that is marked as 'free'. That's why you use good permissions on the file. There are other files in /proc that are sensitive to such fiddling.

      Does 'cat /var/swap' dump a memory map of what's currently swapped out?

      My guess would be 'yes'.

      I've never known that Linux could utilize a swap file rather than a swap partition.

      Most folks don't, a lot of people run their 'desktop' systems like old servers, with multiple partitions and swap spaces. I figure that it saves me time and trouble by using ONE partition and a swapfile, I never have to repartition for space or deal with different /dev/hd?? entries. I've always had better luck by keeping the system as SIMPLE as possible, and part of getting Linux onto JoeUser's desktop will be doing the same thing.

      BTW, I have a quick-n-dirty guide for building a Gentoo system like this, it's still in-progress, but it makes setting up a desktop-oriented Gentoo system nice and easy. I intend to make a script out of it for my monthly 'hmm, I feel like rebuilding against some crazy experimental masked stuff again' moods.

      --
      "Sometimes, I think Trent just needs a cup of hot chocolate and a blankie." -Tori Amos on Nine Inch Nails
    5. Re:Use a swapfile instead of a partition by julesh · · Score: 1

      Pardon my ignorace, but I've never known that Linux could utilize a swap file rather than a swap partition.

      It's mainly only folks who've been around for a few years that know about this. Back in the early 90s, it used to be quite common for people 'trying out linux' to use a umsdos file system, and have swap set up to use the same space as your Windows 3 swap file. That was around the same time that I installed slackware from floppies. :)

  120. hmm by mAineAc · · Score: 2, Interesting

    After reading this I thought to look at my laptop. And what to my surprise I didn't have any swap. It turns out a couple of weeks ago I was playing with swsusp and it had corrupted my swap space and it wasn't loading. I never noticed but after the fact I realized some of the stuff that was going on was because of this. I tried openening a large pdf file and it was taking forever to load and seemed to almost lock up my system. Same thing happened when compiling a few programs and other things similar. I guess with 196 MB of Ram you want to have some swap :)

  121. This stuff is driving me nuts. by Anonymous Coward · · Score: 0

    here's my output from free. free
    total used free shared buffers cached
    Mem: 904732 202036 702696 0 9416 108356
    -/+ buffers/cache: 84264 820468
    Swap: 0 0 0

    this is typical. i hate having a swap partition. i didn't even swap with 384 megs of ram. now with a gig. this whole "need swap" argument is stupid. if adding a gig of swap would help you, then adding a gig of ram instead, would help more.

    will-the ac

  122. Apparently not obvious enough by chriso11 · · Score: 1

    In both cases he is hosed. HOW IS IT DIFFERENT???????

    In case A: 256MB RAM & 256MB swap is hosed
    Case B: 512MB RAM is also hosed

    --
    No, I don't trust in god. He'll have to pay up front, like everybody else.
    1. Re:Apparently not obvious enough by linuxghoul · · Score: 1

      Well, given that he spent more money, added more RAM, as is still hosed when the SAME situation comes up, dont you think his gains would be more worth the dollar if he still kept the swap? This way, certain situations in which he would have been hosed in Case A, he wont have any major problems (beyond the slow slow swap) under Case B

      --
      Sigura Non Grata
  123. WHY we have swap. by Anonymous Coward · · Score: 0

    There are all kinds of facts being brought up here.

    Let's remember one thing, WHY we have swap in the first place.

    We have swap so that we can effectively address and use more RAM than we have physically.

    That is the reason. The ONLY reason.

    All other facts like how we swap out unused pages... we do that because it's more efficient than swapping out often used pages, or swapping indiscriminately. The reason is NOT because "unused pages in ram slow things down" or "they have to be moved somewhere because they are not in use".

    All the fancy algorithms for figuring out what to swap and what not to are just to make swap more efficient... they are not the primary reason swap exists in the first place.

    Swapping makes sense if the performance lost by swapping is less than the gains you get from the extra free physical memory. Perhaps that memory is needed for disk caching. Perhaps you need swap to get enough RAM to run several programs simulatenously, so you can switch between them, rather than load and close them all the time.

    If you have enough physical memory, you don't need swap.

  124. Swap: YMMV by Anonymous Coward · · Score: 0

    I post this from a Solaris perspective....

    What you need from swap depends purely on the activity and needs of your applications. Generally, an NFS server has no need for swap - it only wants to feed clients and use memory for caching filsystem data. What needs to be swapped out? Nothing - file system caches can be flushed back to disk and reused, so no need to go crazy with swap.

    A Sunray server on the other hand might only need say 2G of RAM to perform well enough at peak usage (purely a figure out of the air, but lets run with it). However you might have 50 users logging into it leaving sessions running, but only 10 users active at one time. Those 40 active sessions are just dozens of sleeping mozillas and other session crap. If you need memory for your active users, just throw the inactive processes to swap. So on 2G of RAM you could easily use 16G or more of swap just on idle processes. Why buy 16G of memory just so you dont have to allocate 16G of cheap disk, when 2G of memory satisfies your performance needs?

    Two extreme examples, but they demonstrate the issue - other applications fall in the middle. if you need to page out stuff, you need swap. If not, why bother?

  125. Out of curiousity... by Anonymous Coward · · Score: 0

    How then does a page fault compare (to paging and swapping)?

  126. Swap cannot hurt. by Yartrebo · · Score: 1

    While there are benefits to having extra RAM, removing swap is not a good idea. Even if all currently loaded processes would fit in RAM, it might be a better idea (as decided by the CPU) to swap a few idle processes into swap and cache some commonly used files or pre-load some data. Without swap, all buffers and processes would have to fit in RAM, which would limit the ability of the operating system to cache stuff even if the processes stay within the available RAM.

    If a swapless system beats a system with swap and the same RAM, it's because the operating system has a poor resource management.

  127. Turned it off several months ago... by gweihir · · Score: 1

    Actually I now use kernels without swap support except in some servers. For my desktop computers, I noticed that swap would not go over 50MB usage. With 1GB main memory there is no sense in having the facility at all.

    --
    Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  128. It can't hurt.. by NoMercy · · Score: 1

    So why not have it :)

    True it's annoying if some program got swaped to disk and it's taking a huge time to come back, but that program only got swaped out because something you did required a lot of ram, something you wouln't have been able to do if you didn't have swap, only time I really notice it is when I exit a game like quake3 which has been loading more textures than I can imagine.

  129. Just 'swapoff' by Anonymous Coward · · Score: 0
    (be easier than installing a system without swap).

    swapoff /dev/hdaX

    no need to install a new system. (?)

  130. Damn Windows by BhAaD · · Score: 0

    Windows doesn't give a damn if you have 32MB of RAM or 2048MB of RAM, it will still use swap

    Also, dont tell me you can turn swap off. Well if you look carefully after you turn it off and reboot, swap will re-appear on your installation drive...
    That pisses me off, you turned it off, and it still comes back on, what kinda OS is that?

  131. Cheap, Fast RAM makes swap for new swap ideas by rcpitt · · Score: 1
    This discussion mirrors some of the things I've been looking at over the past couple of months - and my experiences over the past 25+ years with systems with "swap".

    Many of the systems I've been installing and using over the past couple of years have stuck fairly closely to my "one MHz/1Mbyte" rule of thumb. My workstation is 2.4GHz and 2Gigs of RAM for example.

    Despite application bloat (another discussion;) the vast majority of RAM in most of my systems ends up as disk cache. I've limited many of the systems to 10Megs of Swap with one or two spare partitions I can turn on if I'm going to do something that needs more - bringing the total to about 1/2 total RAM in most cases. Old school said you should have 2x total RAM due to need to re-build page tables when RAM got too fragmented. Old Xenix systems (that actually "swapped" as opposed to todays "paging") could get to the point where the OS had to push all but the kernel out to disk and rebuild the RAM image from scratch.

    One of the things I'm looking at (2.4 kernel) is using a file in /dev/shm for "swap" with a high priority and a small (10 megs or so) size, and another larger (partition or file) at lower priority. The kernel seems to need at least a couple of Megs of swap and the /dev/shm/swapfile would satisfy that but still make it FAST! The lower priority disk cache might then soak up the need for any larger swap, and a periodic "swapoff /dev/swap ; sleep 5 ; swapon -p 32767 /dev/swap" would keep it from getting too old and crusty - using a script that would look at how busy the system was to decide if it should run or not (don't run if busy)

    I'm just getting into the 2.6 kernel on a couple of servers and will play with the "swapiness" setting to see what it does in real life.

    On my workstation I'm looking to keep all of the (many - 60+ virtual desktops full) terminal sessions and applications I keep open responsive as I move from desktop to desktop.

    On many of my small customers' servers in many cases I need to balance the needs of a diverse range of server applications such as Samba, NFS, Mysql, EXIM, POP, Spamassassin, DHCP, etc.

    The diverse file activity of the SMTP chain (EXIM, Spamassassin, POP) can soak up a lot of cache, while the need to keep buffer space available for SMB and NFS for fast response has to be balanced with the need for RAM for Mysql's tables.

    As one last point, I'm wondering if the use of the old "sticky bit" (which forced the old swapping systems to keep a program in RAM even if it was no longer active on the theory that things like the shell and cron would be more responsive if they didn't have to be loaded from disk each time they were run) wouldn't give us some more control by allowing us to "nail" a particular application into RAM simply by setting it chmod 1755. I believe this would take a change to the kernel to achieve as I don't believe the sticky bit on files has much if any use on a paged system. I'd love to do this for example for rxvt/xterm.

    --
    Been there, done that, paid for the T-shirt
    and didn't get it
    1. Re:Cheap, Fast RAM makes swap for new swap ideas by rcpitt · · Score: 1

      Sorry for replying to my own post - but it turns out you can't (at least I havn't been able to) make swapon use /dev/shm/swapfile. I'll investigate and post my results on my blog.

      --
      Been there, done that, paid for the T-shirt
      and didn't get it
  132. Re:swap sucks with 2k & xp - disable it if pos by pandrijeczko · · Score: 1
    Under Win9x, you could drop a line into the [386Enh] section of system.ini that read:

    ConservativeSwapfileUsage=1

    This setting supposedly encouraged Win9x to use real memory rather than swap - I don't know if there's something similar you can do in 2K/XP...

    --
    Gentoo Linux - another day, another USE flag.
  133. My solution by Anonymous Coward · · Score: 0

    Calculate a swappiness threshhold based upon six parameters:

    memory latency, bandwidth, size
    swap latency, bandwidth, size

    This swappiness threshhold would measure the amount of diminishing returns in terms of time to swap in and bound this above. System load could be put in terms of these same units, and would give a good indication of when you need additional physical RAM, or need to relax your swappiness threshhold to achieve expected performance.

  134. Scientific apps by Anonymous Coward · · Score: 0

    For scientific apps, we generally use swap=8-10x main memory, and turn off overcommit. This gives us the best performance, and the ability to "fairshare" on our batch system, by suspending tasks to swap.

  135. It doesn't seem that way to me. by edunbar93 · · Score: 1

    This is our pop server, which accepts some 60,000 messages per day and does all the spam filtering on this one machine:

    Mem: 48M Active, 167M Inact, 90M Wired, 18M Cache, 60M Buf, 175M Free
    Swap: 4096M Total, 0K Used, 4096M Free

    It's only got 512 Megs of RAM.

    --
    "No problem. I have the capacity to do infinite work so long as you don't mind that my quality approaches zero."-Dilbert
  136. Nothing beath RAM - except more RAM by phooka.de · · Score: 1

    At work, my machine routinely uses 1.5GB of memory. It has 2GB installed. The part of the filesystem that gets most of the heavy workload holds about 400MB.

    When I didn't use an application for a while, it got swapped out. Now I switched to XP (have to use Windows there, sorry) and disabled the swapfile. Guess what - I'm happier now.

    Why?

    My physical RAM can hold all my apps AND the part of the filesystem (cached) that gets heavy workload. Now I can switch to Mozilla while it's deploying stuff and not wait around a minute for the app to come up.
    And no, I didn't notice longer waits for the ressource-hungry jobs.

  137. Re:You guys will hate my laptop. by Anonymous Coward · · Score: 0

    Trust me, I've got more where that comes from.

  138. Re:swap sucks with 2k & xp - disable it if pos by jilles · · Score: 1

    Windows XP is horribly inefficient when it comes to swapping. I have 1GB of memory which is more than twice as much as is in use normally (typically 300-400 MB). An efficient swapping algorithm wouldn't dream of using the page file with more than 50% of the ram still available for use. Yet this is exactly what windows does. Even if you use some of the essential tweaks (like making sure the kernel is never swapped to disk) you still end up having to wait for the disk when switching between applications. Which is rediculous considering that you probably bought that much memory to prevent swapping (like I did).

    I disabled my pagefile over a year ago (after observing that upgrading from 512MB to 1GB did not reduce the amount of swapping). The effect was very noticable and permanent. At the time I promised myself to use the third memory slot the moment I would get an out of memory error. That has never happened. I run all sorts of games that are known to require lots of ram. This has never caused me any trouble. I play far cry, unreal tournament, flight simulator and lots more, all without runnning out of memory (most of these games only allocate 200-300 MB at most). Unlike with the swapfile enabled, I can switch to my browser and back to the game in under three seconds (e.g. to reply to icq messages).

    Switching between applications is instantaneous, even if you are running lots of them (with swap file enabled this is downright painful). I really can't think of any good reason why I would want to go back to swapping hell.

    --

    Jilles
  139. How to easily disable the swapfile? by Anonymous Coward · · Score: 0

    In windows 2000 or XP, how to disable swap file? I tried setting it extremely small so that it would know not to use much but Windows insist on increasing the size immediately!

    Thanks, and sorry about poor English.

  140. Swap comes in very handy by dtfinch · · Score: 1

    Those few days out of the year when you have to work with something twice as large as memory, in memory.

    Like a seatbelt, you won't be using it most of the time, and it may be an inconvenience at times, but it can save you when you really need it.

  141. Re: understand itself. by Anonymous Coward · · Score: 0
    There are several aplications of 64 bits:
    • GigaPixels photos of maps (travelling, routing, EDA, ..)
    • Virtual Reality: millions of 3D-pieces.
    • Artificial Brain: graphs of millions of nodes for A.I.
    • Complex Games with quasi-full Reality: by example, playing as the Terminator II's evilman.
    • Classifying & processing many videoframes in memory.
    • 64 bit's life of software is of many many years, it's long time to wait for passing to 128 bit.
    • Etc.
    open4free ©
  142. Do we have to argue about swap vs. no swap!? by jriskin · · Score: 1

    It seems fairly clear. In many circumstances swap can be beneficial. But, there are plenty of cases where users would PREFER a message like...

    "You're out of physical RAM, I can either waste 5 minutes swapping until you quit programs, or I can put this process on hold until you quick programs or get back from Fry's with more RAM"

    I think between that and the 'swappieness' setting in the latest kernel and IF that system message was real, I would bitch a lot less about swap. I'm all for VM and OS managed memory, I'm just against using a HardDisk as the medium. HD's are several orders of magnitude slower than RAM.

  143. Swapfile of Mac OSX by elliot2 · · Score: 1

    Does anyone know if the swapfile of OSX still behave like the one in OpenStep? We used to have a very memory eating application on an OpenStep pc and after several days the OS said something like "The swapfile is getting very large (about 1 GB I think), please restart the computer!"

    I heard one have to restart OSX after some days of heavy usage because everything gets slower and slower when the swapfile gets bigger. Don't know if it's true, my iBook has not that big uptime.

  144. The blunt approach... by karlandtanya · · Score: 1
    When I had 512M of RAM, the recommended swap size was about 512M (or 768, depending on who you talk to).


    So, when RAM prices continued to fall (it's a 1998 computer!), I turned off the swap and bought 2 more sticks of RAM.


    Linux has not hiccupped.


    Is there something special about the fact that the swap is on a HDD rather than just RAM?


    My vague understanding is that swap is just fake memory which is cheaper than RAM.


    Anyhow, next machine will be dual opteron; 4G (2 per), and unless something really funny happens, no swap.


    Paying mondo bucks for a processor, then bogging down everything with disk swapping seems silly to me. It seems smarter to go for the slightly cheaper (slower) processor and spend the extra money on RAM.


    Disclaimer: The plural of "anecdote" is not "data".

    --
    "Reality is that which, when you stop believing in it, it doesn't go away." - Philip K. Dick
  145. Is Ram Used Arbitrarilly? by obliviono · · Score: 1

    I have a question about the functionallity of swap space. If I am running 10 applications, 1 - 9 being critical, and 10 being a text version of leisure suit larry.. assuming I have the RAM to carry the first 9 applications, will they reside in the faster memory, leaving good old Larry to reside in swap space? only being swapped in when necessary? Or is it arbitrary, the applications being swapped so that my more critical apps are being moved to the slower, HD space. If so, wouldn't adding SWAP space actually reduce the performance of critical apps? Thanks in advance for /.'s infinite wisdom :).

    --
    ~ Chris
    ObliTech Consulting
  146. Yep, it is by Anonymous Coward · · Score: 0

    especially on my 3B2 with 2MB RAM and SVR3. Also on my 16MB 486/66 that's been running FreeBSD 2.05 since November 1995. That box runs NIS, DNS, and sendmail with a total of about 5GB of SCSI disk. Current uptime is only 34 days (power failure and the UPS ran out of poop).

  147. Re:swap sucks with 2k & xp - disable it if pos by Festering+Leper · · Score: 1

    i never tried forcing it closed... never was able to under win9x .. the whole damn thing was frozen solid during all the thrashing an i didn't want to lose data.

    as far as fragmentation is concerned, a fresh ghost restore and defrag (swap was on windows partition) didn't help. newsbin and its data was on a separate drive.

    when swap wasn't in the picture, disk performance was never a problem (rules out newsbin's own data files). a 4 gig file copy goes in 2.5 minutes and ghost in dos getting 300-600 megs/minute for a restore.

    newsbin may have been poorly optimized as far as that goes, it didn't seem to deallocate all of the ram at once like one would expect, it was something like 4k at a time (per disk stroke)

    anyway, i fixed it by disabling the swap... nobody needs it swapping when there's plenty of ram left now do they? :)

    --
    if you want people to think you know what you are talking about, just put ".com" at the end of everything you say.com
  148. Actually...that was your ARP cache going to shit. by Agent+Green · · Score: 1

    I used to work for BBNPlanet, and there was no problem with traffic caused by customer data, but on a clunky old Cisco 2500 w/ 2 mb of RAM and a couple of class C's, a simple scan would always smoke the box.

    The problem was that for each scanned IP that didn't have an ARP entry, the router would timeout and wait, then fill the cache with an "incomplete" entry. There wasn't much free memory to begin with, but that's probably where your RAM went.

    I won't tell you about Code Red and the customer w/ a Class B attached to his Ethernet0 interface. :)

    --
    // Agent Green (Ian / IU7 / KB1JQO)
    // IEEE 802.3: All 10base Are Belong To Us
  149. One dumb question by bicho · · Score: 1

    Ok
    I am going to make one dumb question.
    Though seeing how late I am in the discussion, It may go unanswered.

    Am I right to think that the limit of SWAP (SW) is such that memory (MEM) and address bus with (W) follow this equation?

    SW+MEM = 2^W

    So that if I have all the physicall ram that my system can adress, swap would be useless? or would cause some trouble to the kernel or would not be possible to turn on?

    Off course, nowaday PC's can address from 4 to 64 Gb (32 bits and some modified to address a bit more, right?) so it is unlikely.

    --

    errera hunamum ets
    1. Re:One dumb question by nagora · · Score: 1
      I think you're wrong because the memory pages are not a single byte, so if an address space of 32bits is working in units of, for example, 10bit blocks (ie, 1024 byte pages) the total capacity might be 32bits+10bits=42 bits. So long as no individual process can have more than 4GB of address space I can't see why this can't work. But I don't know for sure if Linux works this way.

      TWW

      --
      "Encyclopedia" is to "Wikipedia" what "Library" is to "Some people at a bus stop"
  150. or just learn how to use the find command by Anonymous Coward · · Score: 0

    Or you could just not use such an inefficient command like 'grep -r'. Recursive grep is for people who never bothered to learn how to use the find command.

    Chances are, you have some idea of where "oops" would be in /big/filetree. Maybe you are writing a huge project in C, and you're looking for something in a header file. Perhaps you know you shouldn't even bother looking at other people's file, and there is no sense grepping directories, now is there?

    find /big/filetree -name \*.h -type f -user myself -exec grep oops '{}' \;

    this command would only open files that are relevant, and it wouldn't cache all that other stuff that you already know you never should have cached in the first place. Ever wonder why real UNIX systems don't support the -r option for grep? Because find has been around for decades and does the job a whole lot better.

    1. Re:or just learn how to use the find command by Anonymous Coward · · Score: 0

      I don't see that as really answering the question, merely point scoring. Lets replace rgrep with updatedb. Same problem, and it uses find. Apparently that is caused in part by the fact that linux is reluctant to drop cached inodes. Similarly with movies.

  151. I fail to see this debate... by shaitand · · Score: 1

    Swap does NOT improve performance on a system with enough memory for the tasks it performs. THIS can be trivially demonstrated.

    How could you possibly argue swap improving performance in this scenerio. Swap letting you use ram for most often needed memory does NOT make things faster, it makes things faster in a swapping world.

    In a world without swap everything commonly accessed IS ALREADY in memory, you don't need swap to do this. Guess what, everything NOT commonly accessed is also ALREADY in memory so swap doesn't slow down those accesses. ALL the memory accesses are as fast as they can be within the limits of your physical hardware and the software controlling it (kernel).

  152. You could do this in userspace by Julian+Morrison · · Score: 1

    Just write an extension to a standard login shell, and have it sitting on one of the virtual consoles. The extension being: it preemptively mallocs a bunch of memory, sets it as non-swappable, and then does its own memory management inside that fixed chunk of RAM. Use one of those rescue shells with all the simple commands like "ps" built in. Voila, emergency fallback recovery shell.

    1. Re:You could do this in userspace by DunbarTheInept · · Score: 1

      Shells have to load programs to be useful - programs like "ls", for example. And the loading of those programs is something not handled by the shell. It's handled by the kernel's exec() call. Now, granted you could make a shell do all sorts of funky things with "fork" to deal with it's own memory, but unless you re-write the entire workings of "exec" in the kernel, you still have to drop down to the kernel's exec behavior, which will throw your fork'd program's memory away and replace it with the loaded executable, and it will not grab that memory from memory your shell owns.

      Maybe you could have your shell free a bunch of memroy at the line right before the exec(), and then hope that this memory will be eaten by your exec() instead of by some other process, but that's just wishfully hoping you can predict the results of a race condition.

      --

      Don't label something "offtopic" unless you know the topic well enough to tell what's on topic.

  153. need to on WinXP (because of a bug) by lpq · · Score: 1

    Even if you have a gig of memory and never use more memory for programs
    than 300K, and even if you set the memory manager to give priority to running
    programs over file blocks, you will still see NT use swap.

    If you don't give it swap, you won't be able to get various stats related
    to paging (as when it pages a program into memory) since the module that
    shows those stats also tries to show swap stats and basically does a divide
    by zero somewhere and crashes.

    My linux server, on the other hand will use 'zero' swap (even if it is
    allocated, provided I never try to use more memory than I have
    physical). This was in the 2.4 era. Things may have changed in 2.6 to
    make it more like Win XP. Dunno.

    -l

  154. shut down Mars Spirit rover two weeks by peter303 · · Score: 1

    Apparently bad flash memory management shut down one of the 2004 Mars rovers a few weeks after it started. Something like the directory space node lists were being incorrectly updated. The rover appeared to use up all its memory, then tried to reboot over a 100 times over two days to fix the problem. NASA evently transmitted a patch to both rovers. The rovers use a version of realtime, non-virtual UNIX called VxWorks from Wind River. Its been well tested in spacecraft for a couple of decades, but never with a huge amount of flash memory.
    Now would this have happened if the Rovers had a virtual memory UNIX?