Thursday, February 11, 2010

Make Ubuntu faster

There are few very simple methods to make Ubuntu faster. Some of them work not only on Ubuntu, but on other linux systems as well.

Change dynamic linking to static one

When compiler generates binary file, elements which should connect with external libraries are only stubs. When running application for the first time (in a session), it is dynamically linked, which means stubs are replaced with real calls to libraries. This process takes some time. Open Office on my machine runs about 5 seconds for the first time, and 1-2 seconds every next time.

Fortunately there is a program called prelink, accessible from Ubuntu repositories.

sudo apt-get install prelink
sudo prelink -amR

After the second command prelink scans binaries specified in /etc/prelink.conf and modifies them replacing dynamic calls with static ones, but in binary files, so this change is permanent. Disadvantage of this solution is that after every update of processed program we need to run prelink again.

We can always go back to dynamic linking (undo prelink):

sudo prelink -au

You HAVE TO go back to dynamic linking if you want to remove prelink.

Get now what I'll need in a few miliseconds

Next useful program fastening Ubuntu is preloader. It uses magic (complicated algorithms) to predict what data is going to be necessary next and loads it before application asks.

You only need to install it:

sudo apt-get install preload

It should run automatically, but if for some reason it is not running:

sudo /etc/init.d/preload start

Koziołek says it consumes a lot of RAM, but I didn't notice :)

Run services in paralell

If you have more than one core, you can set your system to start services in paralell during startup. This is potentially dangerous, as there might be services which depend on each other.

Edit /etc/init.d/rc and find line CONCURRENCY=none. Change it to CONCURRENCY=startpar.

This post is here courtesy of Bartłomiej "Koziołek" Kuczyński, and is translation of his post in Polish.