Folding@Home performance fix for Ubuntu
For a number of years now, my PC has never sat idle. Its every operating moment has been spent running flat out, looking for a possible cure for cancer, Alzheimer’s disease, Parkinson’s disease and many others. This has been done by running the Folding@Home program. It sits in the background, using any spare CPU cycles that aren’t being used by any other programs you are running. It downloads some data from the servers at Stanford University, processes it, running simulations on protein folding, then uploads its results back to Stanford. It is a great cause, made a little more interesting by the awarding of points for every work unit your PC processes. These points introduce an element of competition - trying to out-produce fellow folders and make your way up the leaderboard. There are teams as well, with their own rankings. I am currently folding for the Overclockers Australia team - currently ranked number 2 in the world and trying to hold onto that spot and make a move to regain number 1.
If you feel like joining, you are more than welcome. Just enter Team 24 when you are setting it up!
Aaaanyway, after updating my system earlier in the year, I noticed my points production had dropped off. What had happened, is that the CPU was not running at full speed: it was throttled back to its slower idle speed. A little fishing around the web turned up this forum thread at techreport.com. It turns out that the CPU speedstep function on was on, with the multiplier dropped back to 6, not 7 (in my case with an intel E6300). The operating system’s frequency scaling control was not treating the folding client as an ‘important’ enough process - it was ignoring the ‘nice’ processes by default. To find what speed the system is running at, open a terminal prompt and enter:
cat /proc/cpuinfo
A bunch of info will come up - look for the cpu MHz field and see if it is the speed it should be. The other way is to install the CPU frequency scaling toolbar applet in Gnome - I have done this and can see at a glance if the cores are running at full speed or not.
To let the frequency governor include ‘nice’ processes, a flag has to be set, as the root user:
sudo su
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/ignore_nice_load
exit
For a dual- or quad-core machine, you may have to do this for all cpus - cpu0, cpu1, cpu2 and so on. An example for the second core:
echo 0 > /sys/devices/system/cpu/cpu1/cpufreq/ondemand/ignore_nice_load
Note that I only had to set it for the first CPU (cpu0) and the other one changed as well.
To make this change permanent, instead of having to re-enter the above commands after each boot, there are two methods, only one of which worked for me. The first method, which did not work, is to add the echo 0 > … line to the /etc/rc.local file, before the line “exit 0″. This did not work for me, as I found out after rebooting.
Instead, I used the second method, found in this thread at the ubuntu forums, involving changing a setting in the Gnome Configuration editor (found under the Applications -> System Tools menu):
Open gconf-editor, go to /apps/gnome-power-manager/cpufreq
and check box consider_nice.
Takes effect immediately.
I believe that the setting in gconf-editor was overriding the setting in rc.local, so it never took effect. After changing that, my system has been happily folding away ever since.
