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:

32-bit164-bit1

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
do
[ -f $CPU_THRESHOLD ] || continue
echo -n 40 > $CPU_THRESHOLD
done

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:

64-bit-fixed2

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.