I live in Omaha.
 
Navigation
 
Search
 
Random Image
9.jpg
 
Me. Elsewhere.
 
Archives
 
Darcy
 
Recently Read
 
Things I Like
Amarok Media Player
 
License
 
F@h Init Script Additions: throttle & unthrottle

As I’ve posted before, I’ve started running Folding@home on my machines. One issue I’ve found is that on a dual core machine I will sometimes bog down as F@h consumes a whole core. That plus a lot of busy Firefox tabs and my box starts to crawl.

To fix that, I added a few pieces to my F@h init script, which was originally scavenged from this site, though on Googling there is a much nicer one on the F@h wiki. You might just want to apply my changes to that one.

In any case, I just added two commands to throttle and unthrottle the F@h application using cpulimit. This way I can add a cron job to manage it, or just throttle it when it starts to bug me.

Here it is if you want it!

#!/bin/sh
 
export DIRECTORY=/var/cache/fah
USER=fah
export OUTPUT=/dev/null
 
test -f $DIRECTORY/fah6 || exit 0
 
 
title() {
  echo $1
  error=0
}
 
status() {
  error=0
}
 
case "$1" in
 
  start)
    title "Starting Folding@Home."
    cd $DIRECTORY
    su $USER -c 'nohup $DIRECTORY/fah6 >$OUTPUT 2>&1 &'
    error=$?
    status
;;
 
  stop)
    title "Stopping Folding@Home."
    killall -15 $DIRECTORY/fah6 || error=$?
    status
;;
 
  restart)
    $0 stop; $0 start
;;
 
  unthrottle)
    FHPID=$(ps aux | grep FahCore | grep [TR]N | grep -v grep | awk '{print $2}')
    CLPID=$(ps aux | grep "cpulimit -p $FHPID -l" | grep -v grep | awk '{print $2}')
    if [ "$CLPID" != "" ]; then
      echo "Killing existing cpulimit, $CLPID"
      kill -9 $CLPID
    fi
    kill -18 $FHPID # It may be in SIGSTOP, so send it a SIGCONT
;;
 
  throttle)
    $0 unthrottle;
    FHPID=$(ps aux | grep FahCore | grep [TR]N | grep -v grep | awk '{print $2}')
    if [ "$FHPID" != "" ]; then
      echo "Found process $FHPID, throttle to 50%"
      nohup cpulimit -p $FHPID -l 50 >$OUTPUT 2>&1 &
    else
      echo "Could not find fah process!"
    fi
;;
 
 
  *)
    echo "Usage: $0 { start | stop | restart | throttle | unthrottle }"
    exit 1
;;
 
esac
 
exit 0

Posted January 13th, 2010 - Permalink
Categories: Geek
Tags: , , ,
You can leave a comment, or trackback from your own site.
 
Possibly Related Posts
 
Adjacent Posts
 
Comments
 
Copyright © 2006 - 2010 John Hobbs
get userping