Personal computing discussed

Moderators: renee, farmpuma, just brew it!

 
just brew it!
Administrator
Topic Author
Posts: 54500
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Throttling Linux client CPU usage

Wed Feb 06, 2008 12:42 am

As most of you are no doubt already aware, the Windows client has a configuration option to throttle CPU usage at a certain percentage. This can be useful if you want to keep the CPU fan from spinning all the way up to minimize system noise levels; I do this on my desktop system at work as the fan is quite noisy when the CPU is at 100% load, and some people use it for machines which are left on at night in their bedroom, so that the fan noise does not keep them awake.

Unfortunately, the Linux clients do not have this option. But with a little simple shell scripting, we can fake it. The following shell script will throttle the folding core(s) at a specified percentage of CPU usage:
#!/bin/bash
OnTime=0.$1
OffTime=0.`dc -e "100 $1 - p"`
while true; do
killall -s STOP -r FahCore_..\.exe$
sleep $OffTime
killall -s CONT -r FahCore_..\.exe$
sleep $OnTime
done

Copy-paste the above script into a text editor, and save it as a file in your folding directory (on my system I named the file fahthrottle). You also need to make sure the "execute" flag on the file is set (use the command chmod +x fahthrottle to set it).

To use, start the folding client as normal; then open another terminal window, change to your folding directory, and enter the command:
./fahthrottle percentage
where percentage is a 2-digit integer between 10 and 90. CPU usage of the folding client will be throttled to the specified percentage.

How it works: Approximately once per second, the script alternately suspends and resumes any processes which have a name of the form FahCore_??.exe. The duty cycle is determined by the percentage you entered on the command line. For example, if you enter a percentage of 65, the folding client(s) are alternately suspended for 0.35 second, then allowed to execute for 0.65 second.
Nostalgia isn't what it used to be.
 
JPinTO
Gerbil Team Leader
Posts: 240
Joined: Sat Jun 30, 2007 7:02 am
Location: Toronto, Ontario

Re: Throttling Linux client CPU usage

Thu Mar 13, 2008 3:53 pm

Thanks for the tip. I modified it a little bit to throttle until a certain hour (in this case until 5pm), then when the scrip stops it will be running full tilt.

#~/bin/bash

until [ `date +%H` -eq '17' ]
do

killall -s STOP -r FahCore_..\.exe$
sleep .3's'

killall -s CONT -r FahCore_..\.exe$
sleep .6's'

done
 
emi25
Gerbil XP
Posts: 367
Joined: Fri Apr 12, 2002 2:18 am

Re: Throttling Linux client CPU usage

Thu Mar 13, 2008 4:05 pm

or, you can replace the cpu cooler with a bigger, fanless one :wink:

Who is online

Users browsing this forum: No registered users and 1 guest
GZIP: On