Friday, May 28, 2010

Feisty Performance - "Fly Like A Butterfly"

This blogpost is a mirror of an old URL ( which does not exist anymore. As there are still plenty of sites linking to it I'm publishing it here so it stays online.

Disable IPv6
At least I dont need ipv6 yet so this is what I do to disable it. In the future there might be some use of ipv6 but until then I’ll keep disabling it.
sudo kate /etc/modprobe.d/aliases
And change the line:
alias net-pf-10 ipv6
alias net-pf-10 off #ipv6
Now comment out all the lines that has to do with Ipv6 in your hosts file.
sudo kate /etc/hosts
This will disable IPv6 on all network interfaces. You need to reboot.

Run boot processes in parallel
This will make upstart to run the boot processes in parallel and speed up the boot process.
sudo kate /etc/init.d/rc
Find and change the line:
Make sure to check your spelling, one little mistype here and you won’t be able to boot!!!
This one seems to do best if you are using SATA or SCSI but even on my old computer with the old ATA it does make the KDM login screen show up a little bit faster.
There could actually be that this tweak slows down your boot if you are using old hardware…

Aliasing hostname to localhost
Right or wrong, you decide. But I picked this up in the Ubuntu forums some time ago and it does improve the startup of some apps.
sudo kate /etc/hosts
and add you hostname to the first line after localhost like this: localhost yourhost yourhost

Disable pango
I know that this is already taken care of in firefox but it still makes a good performance boost to thunderbird and some other apps.
sudo kate /etc/environment
and add:

Disable gettys
Thank’s to some anonymous user for the tip.
sudo kate /etc/event.d/tty3
and comment out the lines starting with start and respawn with a number sign (#).
This does not improve my performance at all but it saves a little resources so why not

It does what you think. It preloads most common used libs and application = faster startup times on your applications (this does not increase your boot speed as some might think).
sudo apt-get install preload
What about prelink?
Prelink is no longer necessary in feisty. Feisty uses a new linking mechanism called DT_GNU_HASH which speeds up the linking process without the need for continuously running prelink.

The default value for vm.swappiness is 60 in Ubuntu Feisty whic is a good default value but if you want to tweak the performance a little bit more you can change this value to a lower value to reduce the load of the swap. If you run the follwing command:
sysctl -q vm.swappiness
You will se that the value is set to 60. And by running:
sudo sysctl vm.swappiness=10
You will change the value from 60 to 10 which will make your system write to swap a lot less and I would recommend this to everyone that has 512 MB of memory or more. If you find that you have very little use of swap set the value to 0. This will not disable the swap but it will make your system write to the swap as little as possible and keep as much as possible in memory. This makes a huge improvement when switching between applications since they are now likely to be in physical ram instead of on the swap partition.
To set your value permanent you need to change the sysctl.conf file:
sudo kate /etc/sysctl.conf
Add the line
To the end of the file. This way it will be set upon boot.
I’ve found that the value of 5 works very good for my use and I have 1 GB of memory.

Grub option profile
There is a option to grub called profile which will profile your startup. What it does is that it kind of indexing all the files read during boot/startup and later on it will find and read those files quicker.
Hit the escape button when booting to get to the grub menu.
Select your default boot kernel and hit the e button.
Go down to the second line and hit the e button again.
Add profile to the end of the line and press enter.
Hit the b button to boot with your new option.
The first time it will take a little bit longer to boot because it has to build the index (or whatever they want to call it) but every boot after this will be a lot smoother.
You need to do this every time you update your kernel or have made other huge changes to your system that might affect the files needed during boot.

Install sysv-rc-conf and disable the services you don’t need at startup.
As an example. On my computer I don’t have bluetooth or PCMCIA so I don’t need to start it at boot time.
So simply disable what ever you don’t have or use.
sudo apt-get install sysv-rc-conf
and then run:
sudo sysv-rc-conf

This is just a general tip. I will not tell you what to remove. You know best what you need…
If you strip down the xorg.conf you can decrease the amount of resources that xorg will use.
sudo kate /etc/X11/xorg.conf
Remove any unnessesary fontpaths, modules and the wacom devices (unless you need them).
By removing the wacom devices you will also get rid of those anoying errors that usually prints out in the console whenever you run an application.

Kernel hacking
Even thought the new kernel in feisty is very good and already tuned a bit there still are some things you can do to the kernel that will make your system snappier and boot up even faster.
Use this thread from the ubuntu forums as a guide on how to compile your own kernel.
master kernel thread
What I do is that I make sure to add the file systems and drivers I use to the kernel instead of loading them as modules. Take out whatever I don’t have or use and then compile my new and hopefully improved kernel
If you don’t want to compile your own kernel there is now a low-latency kernel in the universe repos that you could try.

Disk and file system setup
This is probably the most important thing to think about when you are about to install your computer. The choice and use of the disks and file system is a huge issue when dealing with performance. Depending on your usage of your system you might need to configure your file system different.
For my usage I like to use the following setup (which I think is a good desktop setup).
Mountpoint File system Size
/boot ext2 100 MB
/ LVM, VG=system, XFS 6 GB
/swap LVM, VG=system, swap The size of RAM in your computer. Making it smaller and you will not be able to hibernate.
/home LVM, VG=system, XFS 1 GB, or the rest of the space in that VG
/data LVM, VG=data, XFS The rest of the free space
I’m using the following options in fstab for all my xfs partitions:
Using LVM can really speed up the disk performance. And you get a lot of other good stuff with it as well. Read more about LVM here.
I choose to have /root and /home on one VolumeGroup and /data on another simply because I can then split them up on different physical disks and have them spanning over multiple physical disks witch really speeds up the reads and writes.
What about hdparm?
I have not found any use for hdparm on SATA disks (seems to lack support for SATA). But on older disks there are some things you could tune with hdparm.
Anyhow, since I don’t use it I won’t give you any example on how to use it. Simply search for hdparm on the net and you will find plenty
Defragmentation of XFS filesystem
Until just about a month ago I did not believe that the worlds best file system could get fragmented so I never even bothered to check it out. But then I accidentally came across an article discussing fragmentation on different file systems and I realized that it actually could.
So here is how to defrag your XFS filesystem
make sure that you have xfsdump installed and the run:
sudo xfs_db -r /dev/[your xfs partition]
at the prompt xfs_db> type in frag to view the fragmentation factor and then type in quit to exit the xfs_db util.
If your fragmentation factor is above 10% then I would recommend defragmentation.
Now, to actually defrag the filesystem you need to do this
sudo xfs_fsr -v /dev/[your xfs partition]
And then it is time for a well needed break from your computer for a while.
The results. The one thing that I immediately noticed is that after defragmentation is that the operations browse and delete are much faster on my XFS partitons.
At the moment this is pretty much it but I will update this guide as soon as I discover more performance tunings…

Tuning applications

At the moment there is not so much to add here but this what I like to do.
Use swiftfox instead. It’s optimized for your CPU.
If it’s not already set, disable ipv6. In the url enter about:config and find the ipv6 entry and disable it. And while you are at it change the ui.allow_platform_file_picker to false to change the file dialogs to look a little bit better (if you are a KDE user like me).
Addons I use:
Opens video stream directly in an external video player
A nice gui to tweak the performance of the browser
adblock plus
to disable ad’s it helps a lot
Mouse gestures
Cause it makes the surfing a lot easier…
Gives it a little bit more of a KDE look and feel…
If you don’t need that extras that java JRE provides then simply disable it openoffice. That’s what I do.

Q & A

I followed this guide and managed to screw up, now I can’t boot…
Hey, what can I say. Life’s a bitch…
Well ok then. Here’s something that might help.
Boot up your computer with the Feisty desktop cd
mount your root file system and change/restore your files again.
If you are using LVM then apt-get install lvm and then run vgchange -ay to activate your LVM volumes before you can mount them.

1 comment:

  1. Thanks for making it live again.As it is really a useful and informative blog.But as you said that many sites are linking to it then how will they know about new url?
    digital certificate