[Ubuntu] Why is my computer slow! (jk, but seriously...)

  1. Hepth

    Hepth 493
    Gold Member

    So I know an awful lot about computers. Currently at work they have me on this older Core2 with Ubuntu 12.04 and 2GBs of ram. The computer itself is fast and fine, UNTIL you have some programs open.

    When looking at "htop" (a better version of "top" in unix) I see that if I have mathematica open and firefox, those two programs hit my physical memory barrier of 2GB, and the swap file starts to get larger (maybe >500MB). As soon as this happens the computer becomes unmanagebly slow; as in I cant even click on another program or desktopfile without waiting for more than 10-15 seconds. I can hear the HDD working its butt off too...

    I turned off the 3D GUI/startups/etc so theres no overhead, but I cannot avoid using both firefox/adobe reader and mathematica at the same time.

    Are there any options for proiority of swap file usage in unix/linux that could maybe force mathematica to use more virtual memory rather than physical as it sits? Its not a processor problem but a memory one. Does the sound signify that mayber the HD is going bad and the bottleneck is the writing to swap (the HD is gettign a little louder).

    This is a clean install of Ubuntu. There are no other applications open at all. I remember reading once there were ways to change the swap file's priority. In windows I know what I would do, I would delete the swap, defrag the entire drive, and make a static-sized swap so its in one chunk of the hard drive. Do people do similar things in linux?

    Thanks for any help!
    -Hepth
     
    Last edited by a moderator: Nov 1, 2013
  2. jcsd
  3. Defragging isn't necessary on Linux, but you should definitely have a swap partition, if you don't already.

    To me, that sounds like a bug/memory leak in Mathematica and/or Firefox. Are you by any chance running flash or java applications on Firefox when this happens? They can become really buggy (Adobe dropped native Flash support for Linux some time ago, and especially if you're running older flash apps, they might be really slow.), and it might be worthwhile to try out another browser, Chromium, for example, to see if that's the cause. Are you certain that your programs are up to date (clean installs don't necessary contain the most recent versions unless you have added and/or enabled the correct repos).
     
  4. If you can, take a serious look at how inefficiently you have coded the Mathematica notebook you are using. Sometimes people write Mathematica code in a way that wastes vast resources and they often don't have any understanding of what they have done. Mathematica often doesn't make this obvious. Mathematica is not FORTRAN, it is not c, many users assume it is, but the language is more different under the surface than almost any user imagines.

    If you just cannot rewrite the notebook to make it far more efficient then my stock advice is to give Mathematica 32 gigabytes of real memory. If you give it so much memory that other people think you are a little nuts then you will likely find that this will repay you many times over. Memory is cheap, buy lots and lots.
     
  5. Hepth

    Hepth 493
    Gold Member

    The Mathematica code is not the problem, I know what I'm doing there.

    With no code open (new start, fresh notebook):

    The mathematica "java" binary for JLink takes up 468MB.
    The FrontEnd binaries are at 109MB.
    The Kernel is 176MB.

    So thats about 753MB from just open, blank Mathematica 7.0.

    Firefox only open to PF is at 622MB.

    Unity-2D-shell is 352MB
    Unity-panel-service is 145MB

    So just my GUI with MM and FF open are about 1872MB. Thats very near my limit of 2GB. If I open anythign else, I can hear it moving things to virtual memory (my page/swap partition, which is set at 2GB). the HD sounds a little old, and EVERYTHING gets really slow when its doing it, but doesn't get slow when saving a large file. Not to mention the myriad other Ubuntu things its constantly running in the background (I tried to disable all of them).

    But even so, 2GB of working ram should be fine, I think its just having trouble with the swap. I've used mathematica on much less of a machine, and it could multi-task without a problem. I can't even alt-tab when I have a few things open.

    Maybe I just need to go buy some RAM for this thing out of pocket, or just use my laptop instead of a work computer.
     
  6. Mark44

    Staff: Mentor

    I would guess that running that close to your 2GB limit is what's causing problems. It's not likely that your unused RAM is in nice contiguous blocks, so anything new that's saved to RAM probably has to be tucked in here and there, which could in turn cause problems with the cache needing to be refreshed.

    If there are any slots left for adding another gig or two of memory, I think that would go a long way toward speeding up your computer.
     
  7. So did you run Mathematica with a 753 megabyte footprint on that much less of a machine and do the same calculations within Mathematica you are doing now and it ran just fine?

    So with 128 megabyte free memory if you don't do anything within Mathematica does it run just fine now? Or is this when you start evaluating a notebook and Mathematica begins grabbing all the memory it wants?

    In my experience the reason a system starts hammering the swap space is because Mathematica has consumed all available memory and demands more and more and the system slows to a crawl as half a gigabyte or a gigabyte is continually shoveled in and out of swap.

    But if your footprint has consumed "all" available memory when just idle then I think that has answered the question.

    I don't suppose you have fast USB 3.0 ports and could plug in a really fast 32 gigabyte thumb drive and move your swap space onto that, could you? (Different thumb drives even with the same fast port report more than 10x differences in speed and there doesn't seem to be an easy way of knowing which brand/model will really be fast)
     
    Last edited: Nov 1, 2013
  8. I vaguely remember years ago some reports surfacing about a new release of Mathematica being slow and I think something was finally tracked down to a Java compatibility problem.

    https://www.google.com/search?q=Mathematica+slow+java

    might help you track that down and determine whether that is any part of your problem.
     
  9. Chronos

    Chronos 9,874
    Science Advisor
    Gold Member

    I would recommend adding another 2G of ram. That may not be a solution, but, should help. RAM is dirt cheap so its not an expensive fix.
     
  10. Hepth

    Hepth 493
    Gold Member

    I think the temporary fix they released cut the BG process from about 40% CPU usage to about 20%. I already did this. It also goes away more if I completely disable the JAVA in Mathematica (by makign the files nonexecutable), but then I can't access the manuals/help.

    I have no problem like this on my Windows laptop. Same notebooks. Even when running a calculation, its not a problem. Unix seems to be doing just fine with calculations running at 100% cpu usage too, the priorities I set up are working. It all comes down to when the memory is nearing 2GB of real allocation, and ANYTHING uses the swap.

    I'm willing to bet its not even mathematica, but rather just the ram usage handling in Unix coupled with a HD that I was given by the department that is probably 6 years old and has been reformatted 100 times, and just makes for a really slow swap.

    I doubt this machine has USB3.0. I'm probably better off ordering a small SSD and another few GB of ram.

    Unix systems can handle 8GB+ of ram on a 32bit system right? (Unlike Windows)? Now I just have to find a decent place to get cheap memory in Europe...

    Thank you all for your help!
     
  11. Borg

    Borg 1,098
    Gold Member

    I'll add my vote to this. I was visiting a friend last month that had the exact same problems. He had a single core with 2GB of RAM. I looked up the specs for his memory, picked up 4GB of additional memory and installed it. Problem solved.
     
  12. Ben Niehoff

    Ben Niehoff 1,682
    Science Advisor
    Gold Member

    No. 32 bits will limit you to 4 GB total memory. 32-bit Windows XP is limited to 3 GB total memory due to weirdness in how it's coded.
     
Know someone interested in this topic? Share a link to this question via email, Google+, Twitter, or Facebook

Have something to add?

0
Draft saved Draft deleted