How To Make Firefox Over 40% Faster

If you use Linux on a Laptop, chances are high that you can dramatically improve the responsiveness of all your GUI applications. This tip will work for you if you:

In short, the trick is to disable powernowd and use the ondemand governor instead. How to do this in Ubuntu comes later, let me first show you what this change gets you. In short, you get maximum performance and a longer battery life.

Benchmark

I have a laptop with a Pentium-M that allows frequencies between 600MHz and 1500MHz. Running on 600MHz gives a long battery lifetime and a quiet notebook, on 1500MHz I get good performance. The trick is to switch between the frequencies so that you can have the best of both sides.

This are the rendering times of the CNN site, with different CPU frequency scaling settings. Each measurement was performed 4 times, and the average is show.




Here is an explanation for the graphs:

  1. powersave (600MHz): Since kernel 2.6.9 there are CPU governor in the kernel that allow different frequency scaling behaviour. In the first benchmark the CPU was set to “powersave” which means that only the lowest possible frequency is used. With 600MHz it takes 9.38 seconds processor time to render CNN.com.

  2. performance (1500MHz): The governor “performance” always keeps the CPU at the maximum setting, 3.82 seconds render time is the fastest I can possibly get from of my machine.

  3. powernowd -q -m 3: This one is interesting, here the governor “userspace” was used which means the frequency can be controlled by a userspace application, which in this case was powernowd. The load time is somewhere inbetween the previous two benchmarks, which means that powernowd correctly recognizes that there is a high CPU demand, and switches to the highest frequency. This detection takes quite a bit of time so precious 1.73 seconds are lost compared to what is truly possible with this computer! This is very bad.

  4. ondemand: Finally the glorious “ondemand” governor. This governor switches to the highest frequency if processor usage goes above 80%, and switches back to the lowest frequency where the CPU has less than 80% utilization as soon as possible.

    This is not much different from powernowd, except that it can sample the CPU utilization 25 times per seconds which means it can react in mere milliseconds on a change. Since the governors are kernel modules this does not have the high overhead that a userspace tools like powernowd would have with such a sampling rate. The result speaks for itself, the ondemand governor provides almost exactly the same performance as with constantly running at maximum speed. Not only does it have almost no performance difference to the maximum settings, it is also very good for the battery because it is equaly fast when switching back to lower frequencies.

    For more background information about the algorithm behind the ondemand governor have a look at the paper The Ondemand Governor.

How To Benchmark For Yourself

You do not need anything special for this benchmark, this is how I have done it:

  1. Install the Fasterfox extension, this has a page load timer

  2. Browse to any website (I used CNN since it is a quite complicated site that takes a while to render).

  3. Save the website (File > Save As).

  4. Now enter the name of your saved file into the address bar (e.g. /home/martinus/CNN.html for me). It is important to use the saved file, so that the load measurement contains the raw rendering performance and not how fast you can download.

  5. Wait about 5 seconds, so that you can be sure whatever you use for frequency scaling has switched to the lowest MHz setting.

  6. Press Enter.

  7. Have a look at the timer (lower right corner of firefox) when the page has finished loading.

How To Use Ondemand Governor In Ubuntu Dapper

This is quite simple. See this For a longer description.

  1. Uninstall powernowd

  2. Enable speed stepping (I have a centrino, you might need a different module)

  3. Enable the “ondemand” governor

  4. Switch to the ondemand governor (default is performance). As someone in the comments has pointed out sudo does not work here, so use this:

For permanent settings:

  1. Open /etc/modules and add the following lines (if you do not have a centrino chipset you need to exchange speedstep-centrio with something else)

  2. Install sysfsutils with

  3. Open /etc/sysfs.conf and add the line

39 Comments on "How To Make Firefox Over 40% Faster"

Notify of
avatar
trackback

[…] read more | digg story […]

Anonymous
Guest

This has _nothing_ to do with FIREFOX!!!

Go fishing, please.

martinus
Guest

nevertheless it improves firefox’s rendering performance quite a bit. I could not care less if this is a firefox problem or not, everything that makes it faster it is a good thing. The only reason I wrote firefox in the title is that this was the only application where I could measure the improvement accurately. It also improves typically slow appliations like azureus or eclipse a lot.

trackback

[…] Full Story Explore posts in the same categories: GNU/Linux News […]

Bob
Guest

I’ve use this tweak since a month, and it’s a LOT better than powernowd. Another advantage is that you use less power, powernowd seems to ‘stick’ to high frequencies sometimes when there’s absolutely nothing to process. Ondemand switches immediately back to the lowest freq.

Pierre
Guest

FWIW, I don’t think the sudo line is correct. Replace with:
sudo su -c ‘echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor’

jan
Guest

Firefox is the only appliction that you could test?
wtf?

you can start any program on your computer preceded by the time command to find out exactly how long that command ran, and you say firefox is the only benchmarkable program?

Nie try for a dig front-page pot though.

in a cli, enter:
time anyprogram

it will run, exit, and display how long it took.

Now thats how you benchmark stuff.

ketsugi
Guest

ketsugi@Asahara:~$ sudo su -c

rbnet
Guest

You can’t write to /sys with sudo, you need a “real” root account. I made a small init.d-script to permanently set the ondemand governor at boot time.

mac
Guest

permission denied….

to perform certain actions, such as writing to /sys, you will need to use a traditional root account rather than sudo.

John Flinchbaugh
Guest

What about the “conservative” governor? I’d love to see that one in your little graph. I’ve used that one for a while to try to maximize battery even more and reduce the overhead of switching speeds.

trackback

[…] I wish the little town I set up a super fast network! Should you stop using Google? How to make Firefox work smoking fast! […]

Anonymous
Guest

Does the enable speed stepping module part apply to AMDs too or just Centrino; I think AMD has a thing called powernow. Either way what would be modprobed for an Athlon 64?

Anonymous
Guest

What speedstep module do I use for Dapper on a VM? the real processor is a P4.

Anonymous
Guest

Innocent question – what impact on the battery does the fact that you are looking at the cpu useage 25 times every second have?

theine
Guest

You can

trackback

[…] How To Make Firefox Over 40% Faster […]

knobbt
Guest

How can I determine what kind of cpu I have, and then how to know what modprove to use. /proc/cpuinfo just says Pentium III (Coppermine).

RMX
Guest
For those criticizing this guy for using Firefox instead of other apps — Firefox is *exactly* the kind of application that benefits from his suggestsions. It’s mostly idle, but has very bursty high-CPU needs. Apps like mpeg players won’t benefit – since they’re never idle even the user mode CPU switching will stay at a nice fast CPU speed. Apps like text editors won’t benefit because they never generate large bursts of CPU needs. This guys’s recommendation really benefits FireFox and some graphics editing programs the most; so IMHO it’s good that it’s positioned as a firefox-optimization article.
martinus
Guest

thanks for pointing out that sudo echo does not work, I have fixed this in the article.

Psy-Q
Guest

The powersave governor is called powersave, not powersafe. It doesn’t do anything to make your power any safer.

Chris
Guest

Just replace su with sudo -i and it’ll work when modifying /sys I’m surprised no one else mentioned this ๐Ÿ˜›

Anonymous
Guest

This article is complete bollocks.

But try the ‘conservative’ governor, it works better.

martinus
Guest

anonymous, please try the benchmark yourself with conservative and ondemand. conservative is too slow on the switches, you will loose performance and battery power.

brian
Guest

Actually, the sudo command didn’t work because by default you cannont overwrite a file with sudo.

And Chris, “sudo -i” … that’s not a regular option for sudo on many versions (it’s new as of 1.6.8p[something])

I should know, I’ve been using sudo for over 11 years and was the main port verifer for Irix 6.x and ReliantUNIX

Andy
Guest

brian, “sudo -i” is a standard option for Ubuntu Dapper, the distro the HowTo was originally written for. I should know because Ubuntu is all I use ๐Ÿ™‚

Anonymous
Guest

do sudo -s -H to get root access and try again

discord
Guest

would we use the speedstep-centrino module for a core duo chipset? would we also add 2 lines, one for each processor

devices/system/cpu/cpu0/cpufreq/scaling_governor=ondemand
devices/system/cpu/cpu1/cpufreq/scaling_governor=ondemand

Keith
Guest

I think ondemand is clearly a governor on cpufreq. However, what about those on Mobile Intel Pentium 4 processors? (i.e., those that don’t run on Centrino).

trackback

[…] How To Make Firefox Over 40% Faster < Programming Kung Fu (tags: del.icio.us firefox HowTo links linux reference ubuntu web tutorial tips laptop) […]

trackback

[…] How To Make Firefox Over 40% Faster < Programming Kung Fu (tags: firefox) No Tags .adHeadline {font: bold 10pt Arial; text-decoration: underline; color: blue;} .adText {font: normal 10pt Arial; text-decoration: none; color: black;} […]

trackback

[…] In short, the trick is to disable powernowd and use the ondemand governor instead. How to do this in Ubuntu comes later, let me first show you what this change gets you. In short, you get maximum performance and a longer battery life. […]

Anonymous
Guest

Talk about a misleading title. Get the facts:

http://www.FirefoxMyths.com

Anonymous
Guest

Darn it! You should have mentioned “power management” or some such phrase in your title.

trackback

[…] How To Make Firefox Over 40% Faster (tags: computer linux performance tips tutorial reference) […]

John
Guest
Amusingly, a lot of people are trying to do ‘sudo echo ondemand > /sys…’ and saying “oh you can’t write to sys with sudo” because they don’t understand what they are doing. When you use shell redirects, the shell outputs STDOUT to the file specified. The shell is not a root shell; that’s why you’re using sudo in the first place. In essence, echo is run as root, and then $(id -n -u) attempts to write the output. The comment to pipe to ‘sudo tee’ was good; tee will wind up writing to the file, and will be run as… Read more ยป
trackback

[…] How To Make Firefox Over 40% Faster sudo apt-get remove powernowd (tags: ubuntu linux firefox browser) […]

lozzman
Guest

hey,

i want to know how i can make firefox.exe to high prioroty PERMANENTLY! using a shortcut or the registry, i have mozilla 3.0 ( dont ask why ) and vista home premium!

email me lozzman@hotmail.co.uk

Martin Ankerl
Guest

Hi lozzman! This is very simple in Linux, although I would not recommend it. Glad I could help! ๐Ÿ™‚

wpDiscuz