You are not logged in.

#1 2009-01-11 22:04:39

deltaecho
Member
From: Georgia (USA)
Registered: 2008-08-06
Posts: 185

A faster Firefox

Lately, there's been a lot of hype on Digg about increasing the speed and responsiveness of FF3 by mounting its profile as tmpfs, most of which originated from a post over at the Gentoo Forums, [TIP] Firefox and tmpfs: a surprising improvement.  Personally, I'm one who believes that some things are left better on the HDD than loaded into RAM (for obvious reasons), so, I decided to experiment a little with loopback filesystems.  I tried 2 different FS's, EXT4 (via testing/kernel26) and ReiserFS; the former wasn't impressive, to say the least, but the latter really surprised me.  Here are the steps I took:

1) Back up your current profile (this is an overkill if you know what you're doing):

$ cd ~/.mozilla/firefox
$ current_profile="$( . profiles.ini && echo $Path )"
$ profile_img="${current_profile/default/img}"
$ OLDIFS=${IFS} && IFS=:
$ userinfo=( `grep ${USER} /etc/passwd` )
$ user=${userinfo[2]}
$ group=${userinfo[3]}
$ IFS=${OLDIFS}
$ mv ${current_profile}{,.bak}
$ mkdir ${current_profile}

2) Create a new file image with `dd':

# dd if=/dev/zero of=${profile_img} bs=1M count=200

3) Format the new image:

# yes | mkfs.reiserfs -f ${profile_img}

4) Mount the new file as a loopback filesystem:

# mount -o loop,noatime,notail ${profile_img} ${current_profile}

5) Copy the contents of the old profile to its new location:

# cp -a ${current_profile}.bak/. ${profile_img}
# chown -R ${user}:${group} ${current_profile}

(I had permission issues)

6) Compact all the sqlite db's in your profile (this should be run periodically, BTW):

$ find ~/.mozilla/firefox/${current_profile} -name '*.sqlite' -exec sqlite3 '{}' 'VACUUM;' \;

7) Finally, add an entry to your /etc/fstab:

# echo "/home/${user}/.mozilla/firefox/${profile_img} /home/${user}/.mozilla/firefox/${current_profile} auto loop,noatime,notail 0 0" >> /etc/fstab

Then, put on some flame retardant clothing, sunglasses, and suntan lotion, open your browser, and enjoy the smell of burning silicone as Firefox engulfs your computer in flames big_smile

Note: You can INCREASE your cache size to, say, 65Mb, which will definitely boost the speed at which FF3 loads web pages.  Also, as you probably know, there are many tweaks and tips floating around the internet to further increase FF's performance; check 'em out, its fun to hack-a-fox.  As a last note, if you haven't already, you need to include 'loop' with your MODULES list in /etc/rc.conf.

All in all, this was a fun experiment!

Minor edit: changed FS mount type in fstab from 'reiserfs' to 'auto'

Last edited by deltaecho (2009-01-11 23:46:52)


Dylon

Offline

#2 2009-01-11 23:03:14

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: A faster Firefox

Using it now and it has become snappier! Thanks!

Some notes: my cache was already 200MB/400MB so I made the loop device 500MB
Add auto to the fstab options
And what does that sqlite3 command do? I haven't tried it yet. Can't find anything in man sqlite3.

Offline

#3 2009-01-11 23:45:18

deltaecho
Member
From: Georgia (USA)
Registered: 2008-08-06
Posts: 185

Re: A faster Firefox

Procyon wrote:

And what does that sqlite3 command do? I haven't tried it yet. Can't find anything in man sqlite3.

It is just a little trick I picked up somwhere; you can read about it here.

Procyon wrote:

Add auto to the fstab options

I didn't know about that, thanks!

Another trick I learned, if you ever need to increase the size of the image, do this:

# umount whatever.img
# dd if=/dev/zero bs=1M count=200 >> whatever.img
# mount whatever.img
# resize_reiserfs /dev/loop/0

Dylon

Offline

#4 2009-01-12 00:03:34

Ranguvar
Member
Registered: 2008-08-12
Posts: 2,549

Re: A faster Firefox

Note that without this, a small cache tends to be faster.

Other tips are disabling Pango at compile-time and compiling with -Os instead of -O2, which reduces somewhat both binary size and RAM use. Fasterfox or Fasterfox Lite too, and try tweaking their settings. Then there's simple stuff, like using NoScript, Adblock Plus, etc.

If you do any of these, please do take benchmarks (I will once I do all this again soon). Fasterfox comes with a page load timer, or you can use Extended Statusbar.

Last edited by Ranguvar (2009-01-12 00:04:20)

Offline

#5 2009-01-12 00:44:19

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: A faster Firefox

deltaecho wrote:
Procyon wrote:

And what does that sqlite3 command do? I haven't tried it yet. Can't find anything in man sqlite3.

It is just a little trick I picked up somwhere; you can read about it here.

This seems just a disk space saver, and by the sound of this, "the unused disk space is added to an internal "free-list" and is reused the next time you insert data", I think it will be faster without.

Offline

#6 2009-01-12 01:14:44

deltaecho
Member
From: Georgia (USA)
Registered: 2008-08-06
Posts: 185

Re: A faster Firefox

Ranguvar wrote:

If you do any of these, please do take benchmarks (I will once I do all this again soon).

I've never really benchmarked an application, but I need to check into it (Firefox certainly feels faster, what more do you want? smile ).  All I think I will need to do is duplicate my current profile, modify FF's profiles.ini to reflect the dup, benchmark FF's time using some benchmark app, then switch back to the original one and do the same ... am I correct?

Edit: Ah, you mean page load time, I can do that and will get right to it.

Edit: Here are my stats on a 1001.5 Kbps connection (checked here):

Out of the loop:                           In the loop:

google.com                                 goole.com   
0.633s                                        0.978s               
0.569s                                        0.431s               
0.718s                                        0.435s               

digg.com                                    digg.com
6.300s                                        6.200s
3.300s                                        4.300s
2.400s                                        4.300s

bbs.archlinux.org                        bbs.archlinux.org
1.661s                                       1.206s
0.790s                                       0.841s
0.879s                                       0.773s

slashdot.org                               slashdot.org
10.536s                                     4.921s
2.320s                                       3.591s
1.950s                                       2.956s

kde.org                                     kde.org
2.978s                                      2.343s
2.144s                                      2.905s
2.189s                                      2.572s

kde-apps.org                            kde-apps.org
5.850s                                     2.456s
4.163s                                     4.243s
2.718s                                     2.641s

Ultimately, as far as page load time goes, I don't think there is much of a difference once the page's cache is loaded into RAM.  The main speed gain comes with the load time and responsiveness of Firefox itself, which I need to learn how to benchmark.

Procyon wrote:

This seems just a disk space saver, and by the sound of this, "the unused disk space is added to an internal "free-list" and is reused the next time you insert data", I think it will be faster without.

You probably have more experience with sqlite databases than I do, but unless the psychological effects of hacking Firefox have deceived me, the Awesomebar definitely responds quicker.  If you have any ideas on how to benchmark this, let me know.

(1/11/09) Edited my response to Ranguvar.

Last edited by deltaecho (2009-01-12 02:04:07)


Dylon

Offline

Board footer

Powered by FluxBB