Announcement

Collapse
No announcement yet.

Swap (and low memory) performance

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Swap (and low memory) performance

    I have 4GB of RAM and can quite easily use it all with Firefox, virtual machines, etc. I have a 4GB swap partition. But when I'm short of RAM and the swap gets used, performance is so bad it's practically unusable - the system will take 30s to respond to a window action, minutes to respond to a change of virtual desktop, etc. Even going to a tty console is very slow. Load average (as reported by uptime, tload, etc) goes through the roof.

    Is this true for everyone? Obviously swap is going to be significantly slower than RAM, but does anyone find that it's actually acceptable for occasional use?

    -----------------------
    Some more background:

    I keep an eye on free memory and swap use with the System Load Viewer widget.

    I've tried a swap file in addition to (at higher priority than) the swap partition - no practical difference.

    I've tried vm.swappiness at 60 and at 10 and at 80 - no practical difference.

    Recently I tried disabling swap altogether (thinking because it's close to unusable, I'd rather have out of memory errors). But when free memory ran low, I got exactly the same symptoms, suggesting that it's something to do with the OS "thrashing" with memory pages and not specifically due to swapping. I've been using the stress tool to simulate memory and other kinds of load.

    memtest86 reports no errors; disk tests report no errors.
    CPU is Intel(R) Core(TM)2 Duo CPU T6670 @ 2.20GHz; Kubuntu 11.10 64 bit.
    I plan to buy more RAM anyway, but I also have an LCD panel issue and a battery issue so I'm thinking of a new desktop instead. And an SSD drive!
    I'd rather be locked out than locked in.

    #2
    Originally posted by SecretCode View Post
    I have 4GB of RAM and can quite easily use it all with Firefox, virtual machines, etc. I have a 4GB swap partition. But when I'm short of RAM and the swap gets used, performance is so bad it's practically unusable - the system will take 30s to respond to a window action, minutes to respond to a change of virtual desktop, etc. Even going to a tty console is very slow. Load average (as reported by uptime, tload, etc) goes through the roof.

    Is this true for everyone? Obviously swap is going to be significantly slower than RAM, but does anyone find that it's actually acceptable for occasional use?
    I think that part of the problem is that swap is mostly designed for dumping unused memory pages onto the disk so they can be used by other programs. This becomes a problem when you have more active pages then physical memory which causes it to swap like hell and thrash the disk... I suggest checking your disk io and see if that is the bottle neck.

    Personally I find that if you are using more then a few hundred megs of swap you generally get a massive performance hit and should really get more ram (hell, if you are using any swap you should really get more ram). Or at least reduce your ram usage by quite allot.

    I've tried a swap file in addition to (at higher priority than) the swap partition - no practical difference.
    There should be no noticeable difference between a swap file and partition, if any swapfiles probably perform worst since they need to go through the native file system as well.

    I've tried vm.swappiness at 60 and at 10 and at 80 - no practical difference.
    This will only make a difference when you are reaching the limit of your ram, since it tells the kernel how soon to start swapping, once you are using more memory then you physically have it shouldn't make much difference.

    Recently I tried disabling swap altogether (thinking because it's close to unusable, I'd rather have out of memory errors). But when free memory ran low, I got exactly the same symptoms, suggesting that it's something to do with the OS "thrashing" with memory pages and not specifically due to swapping. I've been using the stress tool to simulate memory and other kinds of load.
    I have had a similar experience when running out of memory, the problem is different then that caused by swap. The problem I had was that new processes where being created faster then they where being killed which caused the system to hang and wait for more memory to be freed which might be the case if you are using a stress tool to simulate the experience.

    plan to buy more RAM anyway, but I also have an LCD panel issue and a battery issue so I'm thinking of a new desktop instead. And an SSD drive!
    I would at least get more RAM, but if you have the money I always recommend a desktop over a laptop for your main computer (with a cheap portable netbook if you also need some mobility).
    Last edited by james147; Aug 30, 2012, 02:20 PM.

    Comment


      #3
      Thanks James
      Originally posted by james147 View Post
      Personally I find that if you are using more then a few hundred megs of swap you generally get a massive performance hit and should really get more ram (hell, if you are using any swap you should really get more ram). Or at least reduce your ram usage by quite allot.
      More accurately, I find that it's when paging out/in is taking place that the system grinds to a halt. If some memory's been paged out but (eventually) active apps have what they need in RAM, then performance is OK again.

      Keen to hear from others as well, if anyone finds that performance is bearable when the system starts swapping.
      I'd rather be locked out than locked in.

      Comment


        #4
        A couple of years back I had a similar experience. I was transcoding and ripping DVD's 2-3 at a time and 4GB's didn't cut it. I went up to 8GB and never looked back Best upgrade I've done in years. I might be buying a couple SSD's soon though so I'll be in heaven all over again when that happens. Obviously, I use a desktop system for this kind of work. Your laptop isn't much use if the monitor and battery are dying and there aren't many laptops that will handle 8GB (maybe more now than I realize). That plus the other expenses means decision time for you. I'd offer you a few parts, but the mailing costs would be more than they're worth.

        What if you upgraded the laptop to a small SSD? Then swap would happen much faster. You could get a small SSD (30-40GB) and an inexpensive external USB case for your hard drive so you could still use it for data storage. I see SSD's on Amazon.uk for around £40 and enclosures for about £15.

        Please Read Me

        Comment


          #5
          Originally posted by oshunluvr View Post
          What if you upgraded the laptop to a small SSD? Then swap would happen much faster.
          I've considered that a bit. Should be possible, but I'd like - actually need - a large enough internal drive as well. I'd need to see if the CD/DVD bay can be used for storage devices. (An external CD/DVD drive would be no hardship.)

          But I'm worried that, since it grinds to a halt even when on low memory with no swap enabled, the speed of drive access may not be the constraint; it may be some kind of CPU-bound memory management load.
          I'd rather be locked out than locked in.

          Comment


            #6
            Originally posted by oshunluvr View Post
            I went up to 8GB and never looked back
            Thoroughly agree with this. When I ordered my current laptop, I decided to give myself a present and go with 8GB instead of 4GB. Talk about bang for the buck.

            Comment


              #7
              This is a subject that's still close to my heart... up until quite recently I was using a 10 year old PC with 1GB RAM, and a slow 40GB PATA HDD which was the boot drive and also where the swap partition lived. As you might imagine, even after installing the "low fat settings", I was in swap hell a lot of the time.

              That's why when I finally scraped together enough cash to get a new machine, I spec'd it with 2 x 4GB RAM modules and an SSD (in addition to a 750GB SATA HDD for the /home partition to live on). Best decision I've made in a while
              sigpic
              "Let us think the unthinkable, let us do the undoable, let us prepare to grapple with the ineffable itself, and see if we may not eff it after all."
              -- Douglas Adams

              Comment


                #8
                I dont know if Id go the SSD route here. I love my SSD, but its not designed to be ram and constantly swapping on it will reduce the lifespan of it drastically. I have swap on my HHD. I think the only thing to do here is buy more ram.

                Comment


                  #9
                  Originally posted by whatthefunk View Post
                  I dont know if Id go the SSD route here. I love my SSD, but its not designed to be ram and constantly swapping on it will reduce the lifespan of it drastically. I have swap on my HHD. I think the only thing to do here is buy more ram.
                  I have read similar comments to this one in the past and I can't for the life of me figure out why people think this way. Maybe someone could enlighten me as to why this idea persists?

                  My thoughts:
                  1. A computer with 4GB of ram is unlikely to be constantly swapping out to ram.
                  2. Even swapping several times an hour is nothing over the life-cycle of an SSD.
                  3. A consumer grade SSD has exactly the same warranty as a hard drive - three years.
                  4. Windows users use SSD's with a swap file that is used way more often than linux user's would be but I don't hear about wildly reduced SSD life-cycles for windows users.
                  5. SSD manufacturers do not prohibit or even recommend against using an SSD for swap files/partitions.
                  6. Hard drive manufacturers are using SSD's as cache for hard drives - which is exactly like swapping memory so they must be up for the job.
                  7. The increased performance-per-dollar of an SSD has to be the best bang for the buck in the computer world right now.
                  8. Why would you bother to upgrade to an SSD and then not use it precisely when it will make the most difference?
                  9. An SSD will be portable. That is to say - easily used on your next computer. However RAM - especially laptop sodimm is very unlikely to be usable on your next computer. A dying laptop is the last place to be putting your computer bucks into unless you have a large cache (is the pun too obvious? ) of money.

                  There are of course totally subjective opinions - I've done no real studies.
                  Last edited by oshunluvr; Aug 30, 2012, 07:53 PM.

                  Please Read Me

                  Comment


                    #10
                    Out of curiosity, what version of KDE are you using? I ask, because I have had the problem you have described in the past and it had nothing to do with swap, but a faulty widget or service (I can't quite remember) You could try creating a new user with a default setup and see if the problem still exists.

                    Comment


                      #11
                      Originally posted by oshunluvr View Post
                      Originally posted by whatthefunk View Post
                      I dont know if Id go the SSD route here. I love my SSD, but its not designed to be ram and constantly swapping on it will reduce the lifespan of it drastically. I have swap on my HHD. I think the only thing to do here is buy more ram.
                      I have read similar comments to this one in the past and I can't for the life of me figure out why people think this way. Maybe someone could enlighten me as to why this idea persists?
                      In the early days of SSDs there was a much more significant impact on lifecycle. Whether or not those early days overlapped with the advent of SSDs cheap enough for average users to consider replacing HDDs with them I don't know, but the need for "wear levelling" technology certainly made good copy for the tech journalists and thus may have perpetuated fears for longer than is necessary.
                      I'd rather be locked out than locked in.

                      Comment


                        #12
                        Originally posted by vw72 View Post
                        Out of curiosity, what version of KDE are you using?
                        I'm on 11.10 (KDE 4.7.4). I suppose I ought to get on and install 12.04 ... I've been meaning to for months but have been busy.
                        I'd rather be locked out than locked in.

                        Comment


                          #13
                          The most swap space I ever needed was 15GB, on this machine which has 6GB of memory, and that was due to an unusual (for me) project, in which I used gimp to convert some 200+ .gif images into a motion .gif "video". Normal use, even with a single Win 7 VM running, rarely runs it above 1.9 or 2 GB of memory being used, and zero swap. I can run two VMs, plus normal packages and a browser, and not go into swap.However, running more than 2 VMs simultaneously will indeed force it into swap. And because a VM is a "running system", it is a different proposition than paging out part of a spreadsheet or some web pages or something static like that. That may be the explanation for the lousy performance when swap is being used by a system running multiple VMs.

                          Comment


                            #14
                            Originally posted by SecretCode View Post
                            I'm on 11.10 (KDE 4.7.4). I suppose I ought to get on and install 12.04 ... I've been meaning to for months but have been busy.
                            When I was having sporadic wait times in KDE, it was also on 4.7.x. I would seriously consider upgrading to see if the problem still exists.

                            Comment


                              #15
                              Originally posted by SecretCode View Post
                              but the need for "wear levelling" technology certainly made good copy for the tech journalists and thus may have perpetuated fears for longer than is necessary.
                              And now that we have file systems supporting TRIM and vastly improved controllers, all those lagacy arguments are history.

                              Comment

                              Working...
                              X