Pages

How to Make the Ubuntu Unity Desktop run Faster?


Unlike in the past, these days almost all the GNU/Linux distributions that pack both Gnome (GTK written) and the Qt/KDE require us to have at least 512MB of RAM by default. Although with the introduction of the Gnome 3, distributions like Fedora 16 for instance now requires you to have about 640MB of RAM or else it even refuse to get installed as well.

This "RAM" jump is actually due to the fact of using much more GPU for drawing the GUI by these desktop. Although it's certainly not the only reason since the Kernel and other applications in general get more heavier as well. Anyhow concerning Ubuntu, with the introduction of the Unity desktop module which uses the Compiz compositing manager by default thus it needs more resources than usual.

So in an attempt to make the Unity desktop run faster disabling the Compiz completely is the mots sensible thing but unfortunately we cannot do that since Unity 3D is a plug-in for Compiz.

But there are few things that we can do. For instance...

*. Use the Unity 2D (Qt written) desktop interface instead -

Update: Starting with 11.10 version, now Ubuntu ships the Unity 2D by default, so you don't have to install it manually anymore.

I know it doesn't sound appealing and when considering the fact that the 2D version does not have all the features of the default 3D GUI ... but this is the single most important thing if you're really concerned about reducing system resources.

*. Get rid of unnecessary start-up applications -

By default Ubuntu (including the Gnome Classic desktop) loads few apps during the start-up process of the desktop that are not required to some users.

So click on the icon next to your user name in the Unity panel and from the menu choose: "System Settings" -> "Personal" -> "Startup Applications" as shown in the below screeshots.

1


2


3



This should bring you a new window that lets you enable/disable start-up applications as shown above. But remember, you should not disable all of these apps since some are necessary to let your desktop function properly.

I've written about this in the past concerning the Gnome desktop ... but it still applies to the Unity as well. So go ahead and read that post if you need more information.

But for most of us, things like Bluetooth manager, Evolution alarm notify, Gnome login-sound, personal file sharing (if you don't have any networked environment), Print queue applet (if you don't use a printer at all), Remote desktop, Ubuntu One and Visual assistance are few of the apps that can be disabled safely. But I humbly advice you to read that post.

*. Install Preload -

This is actually an excellent utility that runs in the background as a system service and act very similar to the Microsoft app pre-fetch. What this does is simple. Say that you usually use 10 main apps. But from that 10, there are 3 applications that are the most prominent.

Lets say that the parts of the applications are scattered all over your HDD which makes them loading a time consuming task for the OS. What the "Preload" does is simple, it makes an index of those most used 3 apps thus accessing them in the future is made easy for the GNU/Linux operating system since now it doesn't have to look all over the HDD... it just reads the index and finds their locations faster than ever which result in a faster application loading times!.

This of course is a very simple analogy and I'm pretty sure the actual scenario is much more complicated.

You can install preload in Ubuntu 11.04 Natty Narwhal by using the below command.
sudo apt-get install preload
Not just for Unity desktop actually, this will help to decrease loading times of any app under GNU/Linux in General. You don't have to tweak or anything, after installing it'll run in the background and will take care of everything automatically for you.

But remember "preload" also loads portions of your mostly used apps during the system boot-up process which could result in a slightly slower booting times (what! :/) but this for most of us will be almost unnoticeable + when considering the enhanced app loading times, in my experience this is more than forgivable :D.

*. "Lower" your Compiz Effects -


Compiz... weird by default ;-)...
Although if you have a powerful GPU then having Compiz with a lot of cool effects enabled by default may not be a big deal. But if you care about making Unity as speedy as possible then you may want to do some manual editing and lower some of the Compiz effects which require significant amount of GPU power. As said this alone should speed-up things quite significantly.

*. Create a Swap partition -

I'm pretty sure you've already done this and have a dedicated partition for your Swap space. But I'm a bit of a freak (bit of a ?, really? :P) and I don't like having partition after partition in my HDD because it gives me headaches.

So I don't have separate swap partition. As a result every time I install Ubuntu Linux I tell the setup wizard to install it without a swap partition. Now this is fine as long as you have 3GB or more RAM on your PC/Laptop (ahh to be rich ;-) ).

But I'm pretty sure many of us don't have that amount of RAM thus even if you have like 1GB and like me don't have a separate swap partition and use Ubuntu without a one, thet seriously create one!.

This is a highly recommended procedure and the only reason that I skip this while installing is that we cannot create a virtual swap space using the installation wizard. But after the installation is completed you can easily add a virtual swap space in Ubuntu which is again, highly recommended + it'll help heavily to make your entire operating system more stable as well.

*. Clean your apt-get Cache -

apt-get is one of the most powerful command-line apps out there that lets you do almost anything under the sun when it comes to dealing with application installations, uninstallations, downloads, etc.

Before installing the applications, apt-get cache them in your HDD (a backup of the downloaded packages). Now one certainly don't need this cache (unless you want to re-install the packages without re-downloading them) + if forgotten for a while then the cache folder can get really big (talking about Gigabytes here). So it's always best to clear this cache.

Don't worry, clearing the cache won't remove the installed apps... so no worries dudes :D. To do this open your GNU/Linux Terminal and enter the below command.
sudo apt-get clean

Make sure to do this from time to time.

*. Remove packages that are no-longer necessary -

This is another big headache for the GNU/Linux users. This is caused by "dependencies". As the name suggest, say that you were installing a package called "A". But to install it Ubuntu may say that it has to download 10 other small packages, these are the "dependencies".

So after installing "A" and after playing with it for a while  (not talking about ex-girlfriends here :/) you got bored and decided to remove it.

But what could happen most likely is that although the app "A" will be removed but the other 10 apps (called dependencies) may not all be removed due to various reasons.

But again using our excellent apt-get, we can safely remove, unwanted dependencies using a single command. This will again help you to cleanup your HDD space + app registry entries which makes your operating system a pain in the *$s to use.

So again open your Terminal and enter the below commands.
sudo apt-get autoremove

*. Clean your Gconf registry entries -


Just like MS Windows Registry, GNU/Linux also has its own way of storing app related information which vary depending on the desktop environment. Unity and Gnome classic use a such "app-registry" called "Gconf configuration system".

So the more apps that you install and remove, as the time goes, some of their "portions" may be left inside of this registry entries thus slowing down your desktop or the OS in general.

Luckily we have an excellent tool called Gconf-Cleaner, a GUI that automatically scans this database and remove these app entries. So within seconds it can remove tens of hundred of registry entries in Unity which should help to enhance the speed.

So use that app and do a bit of a software registry/database cleaning in Ubuntu. Although other than not letting me backup my current database before cleaning ... I did not encounter any issues with it... but use it at your own risk.

*. Update your Web Browser - 

This is another critical thing. These days most of us spend our time with a web browser rather than any other application. But in general all these web browser do consume a lot of system resources (RAM especially). There could be many reasons. One is that it has to!.

Say that you've opened like 20 tabs.. oh well then, you should be willing to sacrifice some system resources mate! :D. But a web browser could also be using unnecessary amount of system resource due to a software bug.

So keeping an updated web browser will not only make it a secure one but also should help to fix those memory leaks which helps you to preserve the system resources as well. 

*. Try to avoid using Ubuntu Software Center -

Although we're being warned by Canonical that with the upcoming Ubuntu 11.10 version there won't be the "synaptic" (the GUI front-end for the apt-get command-line tool) installed by default. But you should be able to install it via their repositories in the future nonetheless.

The point is... as I've said before, the reason I said to avoid USC is not because it uses a lot of RAM but most of the time it requires a lot of CPU usage which make the Ubuntu OS in general a bit unstable (for instance, if you have both Firefox and USC opened at the same time, you're asking for trouble).

"Oi!, at least I'm pretty!" ... yeah right :P

This is because USC heavily depends on using a lot of online source to fetch those pretty icons and other details of packages, user reviews, screenshots, etc (so it's more like a web browser actually) thus it needs a lot of CPU usage when comparing with Synaptic.

So I'm not saying you to not to use it (I know you won't :P) but try not to keep it open for a longer periods at least. But if you have a fast processor and RAM, etc... then this may not be a big deal but unnecessary usage of system could easily drain your Laptop's batter life on the darker side as well :).

*. Remove unnecessary applets -

Since the Unity panel is the application menu bar Canonical's decision not to let users add applets like with Gnome classic panels makes sense. But as a workaround the geeks have come up with another type of applets that runs in your notification area.

Unlike with the old panel applets, these applets do consume a bit more memory since to display at the notification area these applets have to be loaded into the memory where the "old fashioned" applets are just shortcut-icons and require a very little of your RAM, in comparison of course. 

So if you have installed third party applets that you no longer use, then uninstall them or removing the currently running ones should help.

*. Try to limit your Workspace Usage -

Workspace are like virtual desktops in GNU/Linux. The more you use them (more than 1 I mean) the more system resource you're gonna be needing. + With Compiz enabled, every time you click on your "workspace icon" in the Unity application launcher, it uses fancy effects which again needs a bit of a your system resource in general.

So try to limit them to a singe workspace if you can. But because of the way Unity desktop is designed ("doing a single task at once", according to Mark Shuttleworth's own words) for dealing with multiple apps you may have to use the workspace switcher a bit often, but as said, this also needs more system resource in general. So try to limit that.

*. Make Thunar the default file management utility -

By default Unity (both 3D and 2D) use Nautilus as the file management utility. Although Nautilus is already highly simplified still if you're looking for a more lighter version (loads fast, etc) then I highly recommend Thunar which is the Xfce desktop's file manager.



First install Thunar and then follow these official Ubuntu steps to replace Nautilus completely. I personally like Thunar a lot because unlike with Nautilus, newer versions of Thunar even displays a drop-list of information (size, created date, type) for files that you move your mouse hover. This is not possible with Gnome Nautilus since they think that implementing such thing means complexity and scare away the user >:(. 

And also with Thunar you can even edit Tags of audio files directly from the properties window which is also not possible with Nautilus!. If you want multimedia file (both audio and video) thumbnail generating in Thunar, then install the Parole multimedia player as well.

These area actually a handful of things that I could think of helping make Ubuntu Unity desktop runs a bit faster but if you have suggestions and "complaints" :P, then please throw some comments.

21 comments:

Anonymous said...

Really man, this post deserves a 5-star!
Haven't tried all of these yet, but if they work this post is awesome! :)

Gayan said...

@Anonymous,

Thanks dude appreciate it :D.

Although some of the "tweaks" such as the ones associated with cleaning the apt-get cache, etc won't make you say "OMG Ubuntu!" ;-) but a proper optimization of Compiz, swap partition, thunar, etc should help.

Again thanks for the little appreciation :).

Anonymous said...

ya, and about the unity 2d thing. I installed it through terminal and it completed with this message 'lbconfig in process'. Then, i opened gconfig. but there is no unity-2d option under the desktop menu. Help?

Gayan said...

@Anonymous,

It seems that the installation process didn't finish 100%. Please remember that Unity-2d is provided via the PPA which they include daily updates thus this could be a bug.

Anyhow you can either try re-booting the PC and then opening the Gconfig editor OR completely remove the "unity-2d" desktop and re-install it.

To remove it use the below command.

apt-get purge unity-2d

Anonymous said...

SUPERB review,, thanks dude! :D

Gayan said...

@Anonymous,

You are welcome! :).

Carlos Kassab said...

It is a really great article

Gayan said...

@Carlos,

The pleasure is all mine :)

Anonymous said...

I agree in that Unity 3D is a really heavy resource hog.

Saurav Goswami said...

Thanks man ! this post is very helpful

Gayan said...

@AMI BOLCHI,

You are welcome :D.

Anonymous said...

you dont need a swap partition because harddisk is very very slow (on old computer slower) and linux makes ram free from cache

Gayan said...

@Anonymous,

Well, as far as I know, I don't think what you're saying is true :).

It's true the HDD is slow when comparing with other hardware such as the RAM. But, unless you have a lot of RAM (4GB or more), you should have a 'Swap' space which massively helps to maintain a stable PC.

The 'cache' is sort of a virtual 'Swap' file created inside the RAM, which is many times faster than the 'Swap' (of course).

But, GNU/Linux moves data between this 'cache' and 'Swap' when necessary (when 'cache' gets full etc). So again, unless you have a lot of RAM, a 'Swap' file is quite useful.

I'm trying to say that I know better than others or anything, just wanted clarify things so everyone would benefit.

Anyone can correct me, if I'm wrong :).

Anonymous said...

Thanks man i love you

Gayan said...

@Anonymous,

No problemo :)

D said...

In new versions.. Unity 2D comes already available with Unity 3D, and installing another Unity 2D really messes up the recent Ubuntu releases 11-12.04

You can simply switch to Unity 2D from the Login Screen

Gayan said...

@Dave,

I wrote this post a long time ago. Thanks for mentioning it. I updated the post :).

Anonymous said...

Many of these are not really that useful and do not really help in making unity faster specifically. But in making the linux desktop as a whole slightly faster.

The only one that really speeds up the Ubuntu unity desktop is unit-2D. But it is so crippled and buggy. That I was looking for actual advice on how to make the real unity faster.

Workspaces do not increase resource usage by themselves. the apps you place in workspaces do. And to that effect, if you have 20 apps open it does not matter if you place 5 apps in each of 4 workspaces or 20 in a single one.

It is true, more workspaces could in theory make the compiz switch workspace effects slower. But compiz effects are already slow and terrible.

The switch desktop button is what has to be avoided. By using the desktop wall plugin in compiz, you can make desktop switching instant. And in unity-2d, you can just bring a gnome-panel to do workspace switching.





Gayan said...

@Anonymous,

I hear you mate. And when I said to limit the workspace usage, I also assumed using apps in them, otherwise what the use of them anyway.

That being said, even if you don't have any app in a workspace, as soon as you switch to it, then it starts to occupy space of your RAM as well.

And unless there's a nice and stable Compiz effect editor, there's very little we can do to optimize the Unity desktop specifically.

safdar said...

Nice post with great details. I like your job.

Gayan said...

@safdar,

You're welcome.

Post a Comment