Ubuntu Performance

From ConShell
Jump to: navigation, search


Some things you can do to tweak better performance from Ubuntu Linux. Some tips may apply to other distributions and/or Gnome installations as well.

In general it is better to use Xubuntu if you want good desktop performance, it runs the XFCE window manager which is much leaner on memory resources than Gnome, KDE or Unity.

Other bloated applications (pre-installed) can also be found... gnome-terminal measuring in at 34M of Virtual memory. My systems tend to have <= 512MB of RAM, so by following the guidelines below one can make a leaner, meaner Ubuntu.

Use the "top" performance tool

Run the command top and examine the output. Here is what it looks like on my desktop...

top - 21:56:34 up 2 days, 12:11,  6 users,  load average: 0.80, 0.40, 0.55
Tasks:  99 total,   1 running,  96 sleeping,   0 stopped,   2 zombie
Cpu(s): 23.2% us,  1.0% sy,  0.0% ni, 75.8% id,  0.0% wa,  0.0% hi,  0.0% si
Mem:    256320k total,   243756k used,    12564k free,     4320k buffers
Swap:   498004k total,    91412k used,   406592k free,    83952k cached

The load is not bad (.80) but there is over 90M of swap being used! This is due to running too many processes, most of which are doing NOTHING but eating cycles and precious memory. It is noticable when new commands are launched and they take three times longer to appear than expected. Our goal is eliminate the swap usage and cut the number of running tasks (also called processes) by half.

Yes I could go out and buy more memory but it is cheaper and more rewarding to tweak it.

Turn of gdm (or kdm)

All this program really buys you is a fancy (graphical) login screen. It is a glorified version of xdm. The substitute (and equally effective) way to start an X session is to use an .xinitrc file that launches your window manager of choice. Assuming Gnome is your preferred manager, simply put:

 exec gnome-session

into your $HOME/.xinitrc file and disable gdm. You can do this from System->Services but be warned, you WILL kill your X session if you started if from gdm. An alternate way is to bring up a shell and type sudo update-rc.d -f gdm remove and then reboot.

Once rebooted, you can login and type startx to initiate your X session.

Turn off unnecessary services

Suggestions of services to turn off (at your own risk of course) and their memory footprint (estimate).

  • anacron 2936K (unless you turn your computer off at night)
  • atd 1764K (not many people use at to schedule jobs)
  • samba - piggy! (7756K)
  • inetd 1548K
  • avahi-daemon 980K

Remove locate

locate (or mlocate) runs from cron to build an index of all the files in your filesystem. It is a nasty thing and you problem don't need it unless you run the locate command. When it rebuilds the index (the so-called updatedb process) it basically chew up all your I/O capacity. (Recent updates add ionice to the cron, but ionice only works with certain CPU schedulers)

sudo aptitude purge locate

Don't run evolution, thunderbird or firefox

These are heavyweight apps that cost you ALOT of memory, same goes for gnome-terminal.

If you must run these, do so one at a time to avoid hitting swap. Use a leaner e-mail client like Mutt or even Sylpheed. A good lightweight web browser is Chromium, based on Google Chrome.

Don't run gnome-terminal

This beast weighs in at almost 40M of memory! Try a lighter-weight shell instead - I recommend mrxvt.

Don't run gedit (gnome-editor)

This program takes about 22M of RAM. A similarly useful program is nedit and only takes up half of that.

Get back getty!

No I'm not talking about Geddy Lee of Rush fame, but the getty program which sits and waits for incoming terminal connections. Ask yourself, if you are running an X session, how many TTYs do you really need? One should be good enough, that being tty1.

sudo initctl stop tty2
sudo initctl stop tty3
sudo initctl stop tty4
sudo initctl stop tty5
sudo initctl stop tty6
sudo rm /etc/init/tty[23456].conf

Turn off xscreensaver

System->Preferences->Screensaver and choose Disable Screen Saver from the dropdown. Then do File->Kill Daemon (feels good).

Turn off your background

Is it really necessary? I just use a plain brown background. Adjust with System->Preferences->Desktop Background

Adjust systcls

These values can be put in /etc/sysctl.conf and even set while running by using sysctl -w

vm.swappiness = 10