rss
twitter
    Find out what I'm doing on Twitter

Howto Optimize Firefox and Benchmarking

The objective of this blog post is to get better performance on Firefox (resource + bandwidth wise).Feel free to submit your tweaks, extensions via comments so i can update the blog post.

A- Benchmark:

You can benchmark your Firefox performance via Peacekeeper test which is located at here.For speed tests you can use Speed Test tool, but i do not find speed tests reliable.You can also use Extended Statusbar extension that adds speed, percentage, time and loaded size (similar to Opera's one) to Firefox's status bar for benchmarking but before installing it please read B- Extension Optimization section.

B-Extension Optimization:

Mostly we use Firefox because of its extensions and themes but the more extensions we have the more memory will be used by Firefox.So try to remove all extensions except the ones you require.We will install 2 extensions to make Firefox use less bandwidth and resource.
1-Adblock Plus :
You can install Adblock Plus from here.You probably know what this one does, but for the ones who do not know, it blocks and removes the advertisements on websites.This means less page size and mostly less javascript size = less memory.
2-Flashblock:
Flash banners, advertisements, movies and other flashy things sometimes use a lot of CPU power.Flashblock, replaces flash elements with "F".This will decrease used CPU power and bandwidth.If you want to play the flash element, you can do it by just clicking the "F" button.(See the screenshot)

C-Database Optimization:
This is the section you should read at least twice before doing anything.Unlike other sections, this one of my favorite (My fav = Section C and G) but you can damage your Firefox profile (= everything including your bookmarks are gone).Before doing anything :

- You can use FEBE extension, to backup your entire Firefox profile.
- You can manually backup your ~/.mozilla/firefox/ folder.

Firefox stores a lot of data into standalone sqlite database files.They can be found in your profile directory and have the extension .sqlite.We will optimize Firefox databases by removing junk data :

First install sqlite3 package via entering :

$sudo apt-get install sqlite3

to terminal(Alt + F2 > gnome-terminal).

Now you can optimize a single database by entering this command :

$sqlite3 $HOME/.mozilla/firefox/YOURPROFILE/places.sqlite "vacuum"

Do not forget to change YOURPROFILE with your profile folder.For instance the bold one is my profile folder :
/home/duyq/.mozilla/firefox
[duyq@localhost firefox]$ ls
profiles.ini v7vw0o3r.default/
[duyq@localhost firefox]$


So i am gonna enter this command :

$sqlite3 $HOME/.mozilla/firefox/v7vw0o3r.default/places.sqlite "vacuum"

This will ONLY optimize places.sqlite database.If you list the *.sqlite files at your profile folder you will see a couple more :

[duyq@localhost v7vw0o3r.default]$ ls | grep sqlite
content-prefs.sqlite
cookies.sqlite
cookies.sqlite-journal
downloads.sqlite
formhistory.sqlite
permissions.sqlite
places.sqlite
places.sqlite-journal
search.sqlite
signons.sqlite
urlclassifier3.sqlite
webappsstore.sqlite


You can repeat this step OR you can use this bash scripting method :

We will create firefoxoptimize file under /usr/bin/ (you can create it anywhere you want) , we will make it executable and we will place our script insite firefoxoptimize :

$sudo touch /usr/bin/firefoxoptimize
$sudo chmod +x /usr/bin/firefoxoptimize
$gksudo gedit /usr/bin/firefoxoptimize

and paste the following into firefoxoptimize and save it :

#!/bin/bash

killall firefox
find $HOME/.mozilla/ \( -name "*.sqlite" \) -exec sqlite3 {} "vacuum" \;


Now you can run firefoxoptimize command.The script above will basically search for all sqlite databases on your ~/.mozilla folder and execute the vacuum command, to remove junk data.Run the command as normal user (do not use sudo).

Doing this will improve the performance a lot.

PS : I also posted a long script which does the same thing here.But this one is better :)

D-about:config Tweaks:

Open your Firefox and write about:config to your location bar and hit enter.

- network.http.pipelining > Make it True
- network.http.pipelining.maxrequests > Make it 8 or 10
- network.http.proxy.pipelining > Make it True
- network.dns.disableIPv6 > Make it True (to disable IPV6 at Ubuntu Jaunty, please read my Howto Disable IPV6 on Ubuntu Jaunty blog post.)
- plugin.expose_full_path > Make it True
- nglayout.initialpaint.delay > Make it 0 (If this does not exist, create it!)
- browser.cache.memory.capacity > You have to create this if it does not exist (Right-click anywhere, select New, then Integer.write browser.cache.memory.capacity).This is where you decide how much memory to allocate to Firefox.This depends on how much RAM your computer has.If you want 16MB , enter 16384 to the prompt.To see all values and learn more about this, click here.

Edit & Update : You may also want to check my other 2 blog posts (12 + 17 about:config tricks) :
17 Cool Firefox about:config tricks
12 more Cool Firefox about:config tricks

E-Flash Issues:


There are big issues at webstreaming on Linux because of Adobe's flash player (Do not blame Firefox!).You can browse this bug report on Adobe's bug tracker to get some solutions to your problems, especially this one MAY be helpful.

F-Removing Conflicting Plugins:

Ubuntu comes with swfdec plug-in but it will not work on most sites.Installing Adobe's is will solve your problems and so your performance.Open a terminal (Alt + F2, write gnome-terminal, hit enter) and give this command :

$sudo apt-get remove swfdec-mozilla mozilla-plugin-gnash adobe-flashplugin flashplugin-nonfree && sudo apt-get install flashplugin-nonfree

G-Running Firefox Profiles from RAM:

This one also can damage your Firefox profiles like C-Database Optimization section, so i am giving the same advice : backup your profiles!(see that section)

This script will load your Firefox profile into your ram.Unlike other scripts:
-It will ask for the amount of RAM to allocate
-It will ask for the interval you want to synchronize the profile with a copy in the disk, so you can keep any changes after unloading the profile from RAM.
-It saves a tar backup of your profile inside ~/.mozilla/firefox/
-It creates a temporary /etc/fstab.bak
and so......

This is tested on Firefox 3.0.x and 3.5.x BUT there is one important thing if you are using Firefox 3.5: The script will only work if you have at least one profile under ~/.mozilla/firefox/.Shiretoko stores profiles under ~/.mozilla/firefox-3.5 so do not forget to make a symlink to your profile folder inside the ~/.mozilla/ and rename it to firefox!

Install the necessary dependencies by entering this command :

$sudo apt-get install sqlite3 zenity rsync

Download this ramprofile.sh file (It is very LONG to paste the code to this blog post, sorry folks!) to your home directory and make it executable:

$cd && wget -c https://files.getdropbox.com/u/612498/ramprofile.sh && chmod +x ramprofile.sh

The script is well commented (I did not write the script.), so you can read them and understand the script.

To load the Firefox profile at RAM, be sure firefox is not running ($pkill firefox) and run this command at your home directory :

$./ramprofile.sh

Warning: You should always unload the profile from RAM before logging off or rebooting, otherwise the profile content might be lost and the profile might not be unmounted from RAM.

After using Firefox, after a system crash, reboot or something worse :), we will use the following script to unload the profile we used.

Let's download the script to our home directory and make it executable:

$cd && wget -c https://files.getdropbox.com/u/612498/restoreprofile.sh && chmod +x restoreprofile.sh

Run the script via :

$./restoreprofile.sh

EDIT & UPDATE : You can also read my blog post about how to disabling Pango to gain upto %40 speed at Firefox here.

2 comments:

Json said...

Thanks very much for the scoop on speeding up my incredibly sluggish browser.

Can you tell me which of these mods, if any would need to be done again if Firefox is updated via Mozilla?

Binbash said...

Section C , do it around once a week or install Bleachbit system cleaner (i wrote a blog post about it) to do Section C automatically instead of manual.

Post a Comment