Speed up flash and firefox in Ubuntu Jaunty (9.04)!

This is still somewhat of an issue in Karmic (9.10) though it is a bit better. I have more information gathered up from tips from you all and some personal experience with different hardware and such. When I get the time in the next few days I will make an updated blog post for Karmic. Thank you all!

So yesterday I was playing some flash games on pbskids.com with my son, and I realized it was going really really slow. I am running the 32 bit version of Ubuntu 9.04, and I figured I would try out the 64 bit version and compare the speeds, but first I took a few benchmarks to base it upon, I installed hardinfo (which has a few benchmarking utilities in it) from the repositories and also ran Powerbench for flash, and Peacekeeper for the browser.

These are my results:


As you can see the 64 bit version performed a bit better, I also installed the 64 bit Alpha version of the flash player before the test. But, now here comes the interesting part, I added the CPU Frequency Scaling Monitor to my panel by right clicking a blank area on the top panel and going to “Add to Panel”,  then I ran the tests again. On all test with exception to the Flash and Browser test my processor would scale up to 2.4 ghz which is where it should be when under heavy load. Firefox and Flash tests would not scale above 1 ghz.

I had to investigate. I searched all over google about processor scaling on ubuntu then I came across this post. It seems other people have had this problem but this thread seems like it was pretty much ignored. I followed the advice given in the post and added the following lines to my /etc/init.d/ondemand script.  You can type “sudo gedit /etc/init.d/ondemand” in the terminal to access this file.

for CPU_THRESHOLD in /sys/devices/system/cpu/cpu*/cpufreq/ondemand/up_threshold
[ -f $CPU_THRESHOLD ] || continue
echo -n 40 > $CPU_THRESHOLD

In the post he puts his threshold value at 20 I put mine at 40 but you can put it at whatever you want. That value basically tells linux to scale your processor when it reaches a certain load. So if mine reaches a 40% load it will scale it up to 1.8 ghz then 2ghz.. and so on. Ubuntu jaunty seems to have a problem with this value, in the thread it is stated that it is set to 95%, but I cannot seem to verify it because I don’t know how. If it is set at 95% then I think that flash somehow doesnt let its self use that much power, thats my theory anyway. You could turn off ondemand all together by modifying this line in the file:

echo -n ondemand > $CPUFREQ

You would replace ondemand with performance, conservative or powersave. But I would watch those cpu temps. i’ve had mine on performance for a while and haven’t noticed any dangerous temperatures yet. I also would not do this on a laptop since your battery power will drain considerably faster.

So I rebooted and ran the tests again:


As you can see the powerbench and peacekeeper benchmarks have gotten much better since the 32 bit test, and my processor scales as it should now. I cannot guarantee that this will work on your computer, some processors might be set up right but mine wasn’t.  This didn’t seem to be a problem in 8.10, so maybe it is a bug? I dunno. Firefox still scores much lower on the peacekeeper benchmark than it does on a windows system, so sad. Ubuntu is great operating system but things like this really make it look bad to some people.

Oh and yes, I did make this blog just to post this! So thank me or make fun of me I don’t care, I just hope this helps.


20 Responses to “Speed up flash and firefox in Ubuntu Jaunty (9.04)!”

  1. chocolateboy Says:

    Thanks. Your timing’s impeccable!

    This led me to a fix for the slowness I’ve been suffering both with Flash and Firefox generally under Jaunty. I don’t need “ondemand” for my desktop, so I’ve switched (via the CPU Frequency Scaling Monitor applet) to “performance”, which seems to have done the trick. I may make it permanent by editing or disabling /etc/init.d/ondemand, but the applet’s fine for now.

    By the way, it works for me on 32-bit 9.04. I haven’t made the switch to 64-bit yet. If you fancy blogging about how painful or easy it was to upgrade to 64-bit Jaunty, then I, for one, will stick around 🙂

    Thanks again, and welcome to the blogosphere! 🙂

  2. Mike sierra Says:

    Thank you. it is very helpful blog!

  3. krul Says:

    This is really helpful! And I see the default behavior in Jaunty as a bug….this change is really improving my pc performance (AMD Phenom 9500 Quad core)

  4. Jon Says:

    Using 8.10 on a lap top and 9.04 on a desktop WITHOUT widows. I think Ubuntu is getting better, faster and more stable. I do wish there were two things however. ONE a easy recovery disk or restore, for when the grub or boot is damaged. (inframas and the occasional code#)
    TWO a better way to detect and use wireless. I have to say XP has a good way of fining and tapping into wireless. Wish Ubuntu as simpler.
    The only THIRD thing is on setting up the hard drive. either using the whole drive, or using / . /boot , /home, /swap or using all of the / options or none. It seems to me that / with 6g /boot with 1 g /home with enough to fit all docs and photos with a swap / swap 4 g seems to work but I think that is more than is needed for swap.
    However by reducing the size it sure speeds up the install and seems to be faster than using the whole disk or larger areas for each / logical space. But then I am no expert, and this has come from having to reinstall when I think web pages mess up the boot with windows intended mischief. But I hope the experts who have done such a great job around the world of ubnutu will figure out a recovery.
    That Janitor program in 9.04 is pretty cool! Kind of my opinion but if America booted Microsoft out of schools and went to Linux, we might be able to have a lot more money to spend on EDUCATION with less going to old blue screen.

  5. Making the switch to 64 bit Ubuntu. « Brad’s Ubuntu Blog Says:

    […] threshold for your processor which in my opinion is bugged in jaunty, I made a post about it here, it will also tell you more about the benchmarks I performed. So lets get to business, grab your 64 […]

  6. John Bäckstrand Says:

    This fix is nice, but its not a total fix. Compare for example Desktop Tower Defense and Vimeo 720p fullscreen-performance between similar hardware and XP. These are still very slow for me in Jaunty. On proprietary Nvidia drivers.

  7. C.A. Clark Says:

    I did this: echo -n ondemand > $CPUFREQ on my Jaunty system and it made a big difference in flash performance. I also did this:

    Section “DRI”
    Mode 0666

    Section “Extensions”
    Option “Composite” “Enable”

    in /etc/X11/xorg.conf (from this link: http://ubuntuforums.org/showthread.php?t=1152095) separately which seemed to make things even better.

    sounds like from the other comments that there are other considerations, but thought i should report that these two things made a huge difference for my system. i can listen to blip.fm again!

  8. olaf Says:

    Hi Brad,

    Thank you for this post!!! I had already fixed a bunch of intel & xserver performance issues following the wonderful intel + ubuntu performance guide (http://ubuntuforums.org/showthread.php?t=1130582), however, flash videos remained an issue. With the script, my issues are finally resolved and i also created the

    $ sudo mkdir /etc/adobe
    $ echo “OverrideGPUValidation=true” > ~/mms.cfg
    $ sudo mv ~/mms.cfg /etc/adobe/

    configuration to enable hardware accelleration – at least that did no harm.

    Thanks for that!

  9. martincasc Says:

    Well.. I’ve done this, and It seems work better.. Thanks a lot.. But, I’ve been looking for this addres /sys/devices/system/cpu/cpu*/cpufreq/ondemand/up_threshold, and unfotunelly I don’t have it.. I mean, I have cpu0 and cpu1 and not “cpufreq” and so on…

    So, I don’t know If It working or not… I have a Pentium 4…

    There is any tip for check out if this amezing tip it’s working on my CPU?


  10. Isaac Says:

    Hi, total noob at Ubunto,

    My CPU has been maxing out at 100% every time I open Firefox and a flash site.

    I tried the ‘/etc/init.d/ondemand script’ suggestion, and rebooted but I haven’t seen any performance improvement.

    I then tried entering “echo -n ondemand > $CPUFREQ” in the Terminal command line but I got a “bash: $CPUFREQ: ambiguous redirect” reply and my system is still running like a turtle.

    Any suggestions?


    • chocolateboy Says:

      Add the CPU Frequency Scaling Monitor applet to your panel and set the governor to “Performance” there. Don’t forget to wait for a minute after you log in before changing it.

  11. gunnar-medial Says:

    In my case the above made no difference.
    The real revelation came when I ran these two commands:

    apt-get remove swfdec-mozilla
    sudo apt-get install flashplugin-nonfree

    CPU load went down a lot, video stuttering went away.

    This was based on hints found here:

  12. Colin Maddock Says:

    Hello Brad. I’ve tried your tweak to /etc/init.d/ondemand, using the 40 figure, and it certainly made a difference. Here are the Peacekeeper figures. Using Ubuntu 9.04, 32 bit, AMD Athlon 64 X2 +3800 CPU.

    Before tweak
    Firefox 666
    Swiftfox 1086

    After tweak
    Firefox 768
    Swiftfox 1342

    Still not as good as Firefox in WXP on the same hardware though, where the result is 1514! Pity!

  13. Speed up flash and firefox in Ubuntu | kad1r weblog Says:

    […] you have a cpu problem with flash and firefox please read this article. Just add a few line in /etc/init.d/ondemand. for CPU_THRESHOLD in […]

  14. Rafik Says:

    Thank you

    I ran the /etc/adobe commands, and use the cpu applet as suggested and my flash problem is fixed. my machines performance is also tons better, new to ubuntu and had slow pc issues for a while now 🙂 u guys rock.


  15. Cooverlarehem Says:

    Many of folks talk about this matter but you wrote down some true words.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: