Fixing sluggish Ubuntu
There are probably a bunch of articles about this out there, but I just realized it today.
I am using Ubuntu now for over a year as my main OS for work. I am generally very satisfied with it, since it offers a lot of tools for development and also got a great UI. Another plus is that knowing Ubuntu helps me a lot dealing with servers and setting them up for serving web apps.
On Ubuntu Desktop (currently 11.04) I got an annoying problem though. Usually Ubuntu reacts relatively fast, though after operiting with it for some hours and slows down a lot, even sometimes stops reacting for some seconds. This mainly happens when I am opening a new program or sometimes if I just open a new tab in Chrome.
I was wondering what the problem was for some time. First I thought it had to do with Unity, since I can't remember that I had this problem a lot in the older GNOME environment. So my first attempts to google the problem were Unity related and didn't really result in better performance (1).
Today I simply guessed it had to with the Swap space and how Ubuntu swap out memory into it. Surprisingly I was right in the end and changing some default values in some config for Ubuntu did the trick (2). For some reason there is value called swappiness set which determine how often Ubuntu swaps out memory into swap space. The default in Ubuntu is somewhat ridiculous for most desktop PC's (it is set to 60, the range would be from 0-100). So here are the steps how to change the default:
Open the configuration file to edit the swappiness:
gksudo gedit /etc/sysctl.conf
Change the value or add this line (a value of 10 is recommended by the Ubuntu Community):
That's all there is to it. Now my computer is snorring like a cat and many programs nearly open immediately.
I am somehow surprised that the default value for Ubuntu's Desktop Edition is set so high.