Matt Pavelle

Firefox Custom Compile for Intel/OS X

Please note: this article is deprecated as the problems below no longer exist with Firefox.

The Problem:

Mac Firefox versions 3.0 through 3.5.1 suffer from abnormal CPU usage.

My MacBook Pro has 4GB DDR3 @1067MHz and a 2.66GHz Intel Core 2 Duo CPU. It is running Mac OS X 10.5.7.

Firefox can be seen using 97% of CPU0 while essentially idle. This is most noticeable when 3 or more tabs are open. The content of said tabs need not be anything other than static HTML. This is not an issue resulting from extensions/addons or Flash.

Interestingly the CPU usage can be reduced by increasing the disk cache. The default cache of 64M should be more than enough for a web browser, so there must be something else behind this, but I've found increasing the cache to 512M reduces CPU usage to about 50% CPU. This is still too much for an inactive application. Enter: Intel Architecture Optimization.

The Solution:

I've essentially compiled a very specific build of Firefox 3.5.1. For Windows machines, this is mostly irrelevant, as they all run on the X86 architecture, however a Mac can have a G3, G4, G5 or Intel CPU, and the differences can be vast.

I have used optimizations and tweaks in order to make this as fast as possible, thus it should only work on a Core2 based Mac running OS X 10.5 or newer. With this build, my CPU usage has dropped to 4.7% while idle.

Download [download link removed due to deprecation].

Note: The application is named "Shiretoko" as the official "Firefox" name is reserved for official builds.

Do It Yourself!

The Mozilla developers provide an excellent explanation of how to build a generic version of Firefox here: https://developer.mozilla.org/en/Mac_OS_X_Build_Prerequisites. Of course, we're not looking to make a generic build, so after experimenting a bit I've found what I believe to be an optimized build using the following as a .mozconfig:

. $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/ff-opt
mk_add_options MOZ_MAKE_FLAGS="-s -j4"
ac_add_options --enable-optimize="-O3 -march=core2 -pipe -D_FORTIFY_SOURCE=2"
ac_add_options --enable-macos-target=10.5
ac_add_options --with-macos-sdk=/Developer/SDKs/MacOSX10.5.sdk
ac_add_options --enable-profile-guided-optimization
ac_add_options --enable-application=browser
ac_add_options --enable-static-libs
ac_add_options --enable-prebinding
ac_add_options --disable-crashreporter
ac_add_options --disable-debug-modules
ac_add_options --disable-updater
ac_add_options --disable-tests
ac_add_options --without-system-zlib
ac_add_options --without-system-jpeg

Fix the User Agent

After you download and launch the binary, you'll probably want to change the default User Agent as some web applicaitons (hello, Facebook Chat) are improperly coded to disable functionality based on reported User Agents. Here's what you do:

  1. Type "about:config" (minus the quotes) in your address bar
  2. Enter "useragent" (minus the quotes) as a filter
  3. Double click general.useragent.extra.firefox and change the value to "Firefox/3.5.1" (minus the quotes)

And there you have it!

Other Builds:

Chris Latko (http://www.latko.org/downloads/) makes an exclusively Intel optimized build of Firefox. He publishes his optimizations in his mozconfig file and they are very similar to mine.

Adam Michael (http://firefoxmac.furbism.com/) makes builds for G3, G4 7400, G4 7450, and G5 machines. As my Macbook has an Intel CPU, I haven't tested these builds, but they seem promising.

Important Note:

I haven't edited any of the source code. You may download the source directly from Mozilla and build this yourself if you are security conscious.