Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Optimize mozilla-firefox for high performance
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Mike Hunt
Watchman
Watchman


Joined: 19 Jul 2009
Posts: 5287

PostPosted: Sun Sep 06, 2009 12:10 pm    Post subject: Optimize mozilla-firefox for high performance Reply with quote

Here firefox starts in 2-3 seconds after reboot, otherwise ~1 second on a athlon 2.0Ghz system.

The current version is mozilla-firefox-3.5.2, and this is how we did it:

We use LDFLAGS -Bdirect for direct ld binding - it's like prelink but without prelinking.
We use LDFLAGS -Wl,-z,now instead of the default ld -Wl,-z,lazy ld binding.

We compile xulrunner with -O2 and USE custom-optimization
We compile mozilla-firefox with -Os and USE custom-optimization

cat /etc/portage/env/www-client/mozilla-firefox:
CFLAGS="-march=native -Os -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"
LDFLAGS="${LDFLAGS} -Bdirect -Wl,-z,now"

cat /etc/portage/env/net-libs/xulrunner:
CFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"
LDFLAGS="${LDFLAGS} -Bdirect -Wl,-z,now"

cat /etc/portage/package.use:
net-libs/xulrunner custom-optimization
www-client/mozilla-firefox custom-optimization


And run the whole thing through squid as a caching proxy server - the default squid.conf works fine without changes.
Code:
emerge squid
/etc/init.d/squid start
rc-update add squid default

Setup firefox -> Edit -> Preferences -> Advanced -> Network -> Settings -> Manual proxy configuration ->
Code:
HTTP Proxy: <FQDN>
Port: 3128
No Proxy for: localhost, 127.0.0.1

And add iptables rule to iptables.conf
Code:
iptables -A INPUT -p tcp --dport 3128 -m state --state NEW -j ACCEPT


This way firefox starts up fast, pages load fast, it stays fast over time, there is no maintenance required, all this is persistent through upgrades, and it saves bandwidth too. :)
Back to top
View user's profile Send private message
erik258
Advocate
Advocate


Joined: 12 Apr 2005
Posts: 2650
Location: Twin Cities, Minnesota, USA

PostPosted: Sun Sep 06, 2009 6:14 pm    Post subject: Reply with quote

Neat, thanks for posting.
_________________
Configuring a Firewall? Try my iptables configuration
LinuxCommando.com is my blog for linux-related scraps and tidbits. Stop by for a visit!
Back to top
View user's profile Send private message
Mike Hunt
Watchman
Watchman


Joined: 19 Jul 2009
Posts: 5287

PostPosted: Sun Sep 06, 2009 9:36 pm    Post subject: Reply with quote

You are welcome. :)
I thought it might be of interest for people who want a very responsive firefox.
Back to top
View user's profile Send private message
Black
Tux's lil' helper
Tux's lil' helper


Joined: 10 Dec 2002
Posts: 121
Location: Province of Quebec, Canada

PostPosted: Fri Oct 16, 2009 11:56 am    Post subject: Reply with quote

In my case, it had the opposite effect - Firefox takes much longer to start up.
Back to top
View user's profile Send private message
Mike Hunt
Watchman
Watchman


Joined: 19 Jul 2009
Posts: 5287

PostPosted: Sat Oct 17, 2009 1:46 pm    Post subject: Reply with quote

Really, wow. I'm not sure why that would be.

How much longer?

How much RAM is on your box?
Back to top
View user's profile Send private message
Black
Tux's lil' helper
Tux's lil' helper


Joined: 10 Dec 2002
Posts: 121
Location: Province of Quebec, Canada

PostPosted: Sun Oct 18, 2009 1:23 pm    Post subject: Reply with quote

I haven't timed it, but it looked more like 1 second before, and 2-3 seconds after. I've got 2GB RAM, ACCEPT_KEYWORD="amd64".

Anyway, in my case, it doesn't matter, startup time was never an issue.
Back to top
View user's profile Send private message
Mike Hunt
Watchman
Watchman


Joined: 19 Jul 2009
Posts: 5287

PostPosted: Mon Oct 19, 2009 12:17 am    Post subject: Reply with quote

I reverted back to the before way, recompiling xulrunner and firefox with -O2 -pipe and no LDFLAGS and no proxy server.

Firefox starts slower and loads pages slower.

So I recompiled them again with optimizations turned on, and with squid.

Firefox starts faster and loads pages faster. It is snappier and an overall performance boost on my box.

One would expect in the worst case, no change at all. But I am at a loss to explain worse performance.
Back to top
View user's profile Send private message
M
Guru
Guru


Joined: 12 Dec 2006
Posts: 427

PostPosted: Mon Oct 19, 2009 4:42 pm    Post subject: Reply with quote

I will definitely try this these days, although I don't care much about speed of starting firefox (I can wait those extra seconds once a day) but that faster page loading sounds nice, I hope it's not just because of squid. I noticed before that there is a difference in speed between official binaries and compiled version, and that swiftfox seemed faster too.

Also, a few quick tips for optimization that I use is to occasionally vacuum sqlite files in mozilla profile. I also mounted firefox profile in ram, I can dedicate 64mb for firefox, and only 25 is used actually since I removed urlclassifier, there was a thread about this, and with this location bar is much snapier.
Back to top
View user's profile Send private message
zyko
l33t
l33t


Joined: 01 Jun 2008
Posts: 617
Location: Munich, Germany

PostPosted: Mon Oct 19, 2009 11:04 pm    Post subject: Reply with quote

Quote:
We use LDFLAGS -Bdirect for direct ld binding - it's like prelink but without prelinking.
We use LDFLAGS -Wl,-z,now instead of the default ld -Wl,-z,lazy ld binding.

We compile xulrunner with -O2 and USE custom-optimization
We compile mozilla-firefox with -Os and USE custom-optimization


I haven't tried it yet, but would you please elaborate a little: Why is this supposed to improve performance versus the defaults?
Back to top
View user's profile Send private message
Mike Hunt
Watchman
Watchman


Joined: 19 Jul 2009
Posts: 5287

PostPosted: Tue Oct 20, 2009 12:02 am    Post subject: Reply with quote

A few years ago, this would have been ricing. But not anymore. The devs both at Gentoo and upstream have been working very hard on implementing these (and other) linker directives into our open source software. The result is that it can make applications respond noticeably snappier/faster - at least on my box. But apparently this is not always true - see above posts.

So if you wish, you can try - it cannot do any harm and is easily reversible.


Quote:
ld -z now
Equivalent to gcc -Wl,-z,now (which is probably preferrable, since I write C++ and always use the g++ frontend), this tells the dynamic linker to resolve symbols on program start instead of on first use. I’ve noticed that sometimes, the first run through a particular code path results in a latency of 800 milliseconds. That’s huge; that’s big enough for a human to notice with the naked eye. For server processes, that generally also means that the first request serviced on startup blows chunks, latency-wise. While it may not make a huge difference in the grand scheme of things, it’s nice to be able to pay the cost of symbol lookup up front instead of at first use.


Quote:
By passing -Bdirect at link time, the build process can cause many symbols to be directly linked, allowing the dynamic linker to severely decrease the search space during lookup.

Code:
# quse -D custom-optimization
 local:custom-optimization:net-libs/xulrunner: Fine-tune custom compiler optimizations
 local:custom-optimization:www-client/mozilla-firefox: Fine-tune custom compiler optimizations


Of course, this will not make a celeron-750MHz load firefox in 2 seconds. Clock speed is one thing, fine-tuning is another thing. At any rate, I like it enough that I thought I would share it. :)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum