Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Seti@Home (and other apps) only on available cpu-cycles
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Matje
l33t
l33t


Joined: 29 Oct 2002
Posts: 619
Location: Hasselt, Belgium

PostPosted: Tue Jan 28, 2003 6:28 pm    Post subject: Seti@Home (and other apps) only on available cpu-cycles Reply with quote

After reading this url I decided to try and improve my system performance a bit. I followed the link to Con Kolivas his homepage with patches. After sniffing around some I noticed the batch O(1) scheduler patch. This enables you to run a task in the background, so I decided to try and go for it. It is a whole difference with using nice I must say. I used it on Seti@Home and did some testing.

First I ran Seti@Home regulary with a nice value of 19 and then I started UT2003 (yes, that's the heaviest thing I got :-)) I switched to a console and top'ed (is that even a verb? :-)) Seti@home got 50% CPU, UT2003 got 50% too. Apparently it needs a lot more because it stuttered like hell :-) I then tried using it in batch mode, and yes, it r0x0red... UT used 'bout 70% while Seti@Home got the rest. I could play smoothly (for as smooth as it gets with a GF2MX ;-)). So I decided that from now on, I'm running Seti@Home as a background task, so I don't need to turn it off and on again, which I allways forgot :-). Of course you can also use this for other stuff, like Zetagrid. Here's how to do it:

First, you need the kernel patch off course. If you're using the latest ck-sources, you allready have it in your kernel. You can find the patch here: http://members.optusnet.com.au/ckolivas/kernel/ Get the 001_o1_pe_ll_021215_ck_2.4.20.patch.bz2. This patch is for kernel 2.4.20. It also includes some other patches of CK. If you want earlier versions, go here: [url]http://people.redhat.com/mingo/O(1)-scheduler/[/url] I couldn't find the single patch for 2.4.20 so I installed the one of CK.

Please note that patching the kernel may b0rk your system. While I was writing this my system just hang, something that never happened to me before unless I invoked it myself somehow. Now I was just writing :-) I'm going to try and disable the other stuff in CK's patch and see if that helps. It's up to you to choose what you do :-) Also, CK doesn't garantee that the patch will work with allready patched kernels like xfs-sources or gentoo-sources. It worked fine with my bootsplash-patched vanilla-sources though.

Let's get to the point. You've downloaded the patch, move it to /usr/src/linux. Then do this:
Code:
# cd /usr/src/linux
# bunzip2 001_o1_pe_ll_021215_ck_2.4.20.patch.bz2      // <== Comment: this is what they invented tab for :-)
# patch -p < 001_o1_pe_ll_021215_ck_2.4.20.patch


This will patch your kernel. It is possible that it will complain it couldn't patch Makefile, just ignore this, it is only a version bump that fails, in fact, if it'd work you'd get a -ck behind your kernel-version. If you still want that, open the Makefile and change the following:
Code:
EXTRAVERSION = -ck


Next, if you have the CK-patches, and you don't want to enable other stuff that may b0rk your system do
Code:
# make menuconfig

and disable the following:
Code:
Processor type and features ==> Low latency scheduling
Processor type and features ==> Preemptible Kernel

Note: I haven't tried disabling this myself yet, it may be possible that the scheduler won't work if it's disabled, couldn't find any info on this, but I think that it's safe.

Then:
Code:
# make dep && make clean bzImage modules modules_install

I'm not sure if you need to recompile you're modules, I did so because I added another module I needed. But I would do it if I were you !!! Since the patch changes basic kernel functions, it could be (and probably will be) possible that it b0rks your modules too. It's not worth the hassle afterwards :-)

Next copy the bzImage to your /boot (don't forget to mount /boot and make a backup of your bzImage, or create a new entry in grub/lilo)...
Code:
# mount /boot
# cp /boot/bzImage /boot/bzImage.backup
# cp arch/i386/bzImage /boot/bzImage


Now you can reboot and see if your system isn't b0rked :-)

There are some utils available which should make it possible for you to put a process on the batch list, but I found them not to be working. You can try them if you want though: schedtool, which is deprecated over sched-utils. The latter is also in the portage tree, but it's a very old version.

I use a script I found [url=http://people.redhat.com/mingo/O(1)-scheduler/]over here[/url] instead:
Code:
#include <time.h>
#include <stdio.h>
#include <sched.h>
#include <stdlib.h>
#include <sys/types.h>
#include <linux/unistd.h>

int main (int argc, char **argv)
{
   int pid, ret;
   struct sched_param p;

   p.sched_priority = 0;

   if (argc != 2) {
      printf("usage: setbatch <pid>\n");
      exit(-1);
   }
   pid = atol(argv[1]);

   ret = sched_setscheduler(pid, 3, &p);

   if (ret) {
      printf("could not set pid %d to SCHED_BATCH: err %d.\n", pid, ret);
      return -1;
   }
   printf("pid %d is SCHED_BATCH from now on.\n", pid);
   return 0;
}


Save it somewhere as setbatch.c and while in the directory, type:
Code:
# gcc setbatch.c -o setbatch
# mv setbatch /bin/


Now, whenever you get the pid of a process, you can send it into the batch mode by doing
Code:
# setbatch <pid>


My objective was too make Seti@Home run all the time, so here's how to do that.

First, off course, you need Seti@Home, if you don't have it allready, emerge it:
Code:
# emerge setiathome

You can off course set this up how you like yourself, but this is how I did it. I start Seti@Home as a init-script, so the owner of it will be root, but I also use TKSeti, so I can check my status now and then. So I needed a folder other then the default ~/setiathome, because my user (obiously) can't read /root/setiathome.
Code:
# su -
# cd /
# mkdir setiathome
# chmod a+rwx setiathome
# cd setiathome
# setiathome


The last step will start to ask you questions to setup an account, or import an existing one if you allready have one. After it's done, it states something about this being the last message and that it has started looking for aliens. Ctrl-C when you got this message.

Next we need to alter the init-script a little bit, so:
Code:
# pico -w /etc/init.d/setiathome

Or use nano, or vi, or whatever :-)

Go down to where it says ./setiathome ${... change that line to:
Code:
/bin/setiathome ${SETIATHOME_OPTIONS} >&/dev/null&

and directly under it, add this line:
Code:
/bin/setbatch $(pidof setiathome)

Save it and exit.

You also should change the file /etc/conf.d/setiathome to your needs, just make sure the dir is correct:
Code:
SETIATHOME_OPTIONS="-nice 19 -proxy proxy.pandora.be:8080"
SETIATHOME_DIR=/setiathome


I haven't experienced with changing the nice setting while using scheduling yet. It works fine for me at the moment, so I think I'll keep of it :-)

Try the script, it should work from the first time :-)
Code:
/etc/init.d/setiathome start


You can check if setiathome has actually started by doing
Code:
# ps aux | grep setiathome

It should state something like this:
Code:
root      1605 95.1  5.8 16660 15128 ?       RN   17:59  60:49 /bin/setiathome -nice 19 -proxy proxy.pandora.be:8080

If it doesn't, it's b0rked, start looking for problems or crying for help ;-)

If you want to check if your program is actually in the schedule batch, you need to install sched-utils. You can either emerge it or do like I did, install the newer version I would suggest the latter because I think the one in portage tree is outdated. Just download it somewhere and:
Code:
# tar -xzf schedutils-1.1.0.tar.gz
# cd schedutils-1.1.0
# make
# make install


Now to check if the process is in the scheduler:
Code:
# lsrt
PID      CLASS        PRIORITY   CMD
1605     (unknown)    0          /bin/setiathome


If it isn't there, start yelling again :-)

Again: I don't take any responsibility if this screws up your system, that's life on the bleeding-edge :P
_________________
Life is like a box of chocolates... Before you know it, it's empty...
Back to top
View user's profile Send private message
Matje
l33t
l33t


Joined: 29 Oct 2002
Posts: 619
Location: Hasselt, Belgium

PostPosted: Tue Jan 28, 2003 8:05 pm    Post subject: Reply with quote

Just to give another example:
Currently I'm compiling apache + mod_php + mysql, and setiathome stays below merily with 0.0% cpu usage...
_________________
Life is like a box of chocolates... Before you know it, it's empty...
Back to top
View user's profile Send private message
grafty
n00b
n00b


Joined: 27 Jan 2003
Posts: 33

PostPosted: Wed Jan 29, 2003 2:55 am    Post subject: Re: Seti@Home (and other apps) only on available cpu-cycles Reply with quote

Matje wrote:

There are some utils available which should make it possible for you to put a process on the batch list, but I found them not to be working. You can try them if you want though: schedtool, which is deprecated over sched-utils. The latter is also in the portage tree, but it's a very old version.

I use a script I found [url=http://people.redhat.com/mingo/O(1)-scheduler/]over here[/url] instead:


I got bored, so I made ebuilds for all of these. :)

setbatch
This is Ingo Molnar's C program, used in Matje's post. It is a simple C program called setbatch where you pass the program a PID and it changes the process to use batch mode. From what I could tell from the code, this program CANNOT set the process back to normal mode.

schedtool 0.8
This is the latest version of schedtool. It is based on the setbatch program above, with the additional capability of being able to query the scheduling mode of a PID, as well as being able to set the scheduling mode to any of SCHED_NORMAL, SCHED_FIFO, SCHED_RR, or SCHED_BATCH. Note that the use of SCHED_FIFO or SCHED_RR requires root privileges. Matje said that he couldn't get this to work, but I was able to get it to work fine. YMMV. This is my personal preference.

schedutils 1.1.0
This is the newest version of schedutils (the current version in portage is 0.0.8). Sadly, the developer of schedutils took out the batch functionality of his tool as of version 1.1.0, so you cannot use this version to set batch mode of a process. This would explain why matje was unable to get it to work. If you can find version 1.0.0 or lower (for example, the version 0.0.8 in the portage tree), it will have a "chbatch" program that works similarly to schedtool. Despite version 1.1.0's uselessness with respect to batch mode, I include it in case you want to use it.

They are very simple ebuilds, and thus I only performed minimal testing (they emerge and unmerge fine on my machine). Use at your own risk. :)

Let me know how they work...[/i]
Back to top
View user's profile Send private message
Matje
l33t
l33t


Joined: 29 Oct 2002
Posts: 619
Location: Hasselt, Belgium

PostPosted: Wed Jan 29, 2003 10:19 am    Post subject: Re: Seti@Home (and other apps) only on available cpu-cycles Reply with quote

grafty wrote:
From what I could tell from the code, this program CANNOT set the process back to normal mode.

That is correct. If you feel like doing some pogramming, open /usr/src/include/sched.h and look for a function that does this :-)

Quote:
Matje said that he couldn't get this to work, but I was able to get it to work fine. YMMV. This is my personal preference.

If I tell it to set a mode to SCHED_BATCH, it tells me that it doesn't know that mode...

Quote:
This would explain why matje was unable to get it to work. If you can find version 1.0.0 or lower (for example, the version 0.0.8 in the portage tree), it will have a "chbatch" program that works similarly to schedtool. Despite version 1.1.0's uselessness with respect to batch mode, I include it in case you want to use it.

The sched-utils lost that functionallity because SCHED_BATCH isn't getting into the 2.6 Kernel, at least I read something like that somewhere...
_________________
Life is like a box of chocolates... Before you know it, it's empty...
Back to top
View user's profile Send private message
Gnufsh
Guru
Guru


Joined: 28 Dec 2002
Posts: 400
Location: Portland, OR

PostPosted: Wed Jan 29, 2003 11:20 am    Post subject: Reply with quote

I can't get this to work with folding at home.
schedtool -B 'pidof foldingathome'
doesn't work, although pidof returns all of foldingathome's pids. Just doesn't showup with lsrt.
Back to top
View user's profile Send private message
Matje
l33t
l33t


Joined: 29 Oct 2002
Posts: 619
Location: Hasselt, Belgium

PostPosted: Wed Jan 29, 2003 4:48 pm    Post subject: Reply with quote

Try this:
schedtool -B $(pidof foldingathome)
_________________
Life is like a box of chocolates... Before you know it, it's empty...
Back to top
View user's profile Send private message
Gnufsh
Guru
Guru


Joined: 28 Dec 2002
Posts: 400
Location: Portland, OR

PostPosted: Thu Jan 30, 2003 2:12 am    Post subject: Reply with quote

Thanks, that gets the initial pids. The problem is, fah just benchmarks the system, it calls a differentt core program to do the work, and the core will be chosen depending on the kind of WU. So, how do I get all the process spawned by fah into the batch scheduler?
Back to top
View user's profile Send private message
grafty
n00b
n00b


Joined: 27 Jan 2003
Posts: 33

PostPosted: Thu Jan 30, 2003 2:31 am    Post subject: Reply with quote

Gnufsh wrote:
Thanks, that gets the initial pids. The problem is, fah just benchmarks the system, it calls a differentt core program to do the work, and the core will be chosen depending on the kind of WU. So, how do I get all the process spawned by fah into the batch scheduler?


When a process is assigned to SCHED_BATCH mode, any child processes that it creates are also assigned SCHED_BATCH mode. If you look at the schedtool documentation, it even suggests that you put your shell into SCHED_BATCH mode so that all of your shell-started tools (like compilation or whatever) get started in SCHED_BATCH mode as well. To do this, you would put the following line in your ~/.bashrc file:
Code:
schedtool -B $$

I personally don't do this, but if you find yourself doing a lot of CPU-intensive things from the command line (like compilation), you might want to think about it.
Back to top
View user's profile Send private message
Matje
l33t
l33t


Joined: 29 Oct 2002
Posts: 619
Location: Hasselt, Belgium

PostPosted: Thu Jan 30, 2003 10:56 am    Post subject: Reply with quote

I also don't do that. I tried it but when doing heavy stuff, it takes ages for my gnome-terminal to pop back to the front if it's been minimized.
By the way, schedtool works for me too, was using it the wrong way :-)
_________________
Life is like a box of chocolates... Before you know it, it's empty...
Back to top
View user's profile Send private message
grafty
n00b
n00b


Joined: 27 Jan 2003
Posts: 33

PostPosted: Fri Jan 31, 2003 3:00 am    Post subject: Reply with quote

Matje wrote:
I also don't do that. I tried it but when doing heavy stuff, it takes ages for my gnome-terminal to pop back to the front if it's been minimized.

You're not SCHED_BATCH'ing the gnome-terminal, are you? You should be SCHED_BATCH'ing the "bash" that it starts. The gnome-terminal itself should be unaffected...
Back to top
View user's profile Send private message
Matje
l33t
l33t


Joined: 29 Oct 2002
Posts: 619
Location: Hasselt, Belgium

PostPosted: Fri Jan 31, 2003 11:51 am    Post subject: Reply with quote

Ehm... OFF COURSE I WASN'T !!! :oops: :oops:

:lol:
_________________
Life is like a box of chocolates... Before you know it, it's empty...
Back to top
View user's profile Send private message
Gnufsh
Guru
Guru


Joined: 28 Dec 2002
Posts: 400
Location: Portland, OR

PostPosted: Sun Feb 02, 2003 10:55 pm    Post subject: Reply with quote

For some reason, foldingathome is showing up in the batch scheduler, but FahCore_65.exe isn't.
Back to top
View user's profile Send private message
Fitzsimmons
Guru
Guru


Joined: 01 Jan 2003
Posts: 415
Location: Waterloo, Ontario, Canada

PostPosted: Tue May 20, 2003 1:19 am    Post subject: Reply with quote

Sorry for being a n00b... does the script you provided (Matje) set the program to the lowest possible priority? Or do I still need to nice -n 19 it? And what exactly is "batch mode"? Thanks.
Back to top
View user's profile Send private message
BeFalou
n00b
n00b


Joined: 26 May 2003
Posts: 45
Location: Madrid

PostPosted: Sun Dec 28, 2003 3:43 pm    Post subject: Reply with quote

ssjf wrote:
And what exactly is "batch mode"?

Ive the same question. I tried to run it without putting it in batch mode and it made no (performance) difference to me. If someone could explain it ...

Thanks.
Back to top
View user's profile Send private message
Boris27
Guru
Guru


Joined: 05 Nov 2003
Posts: 562
Location: Almelo, The Netherlands

PostPosted: Fri Jun 11, 2004 7:09 pm    Post subject: Reply with quote

Gnufsh wrote:
For some reason, foldingathome is showing up in the batch scheduler, but FahCore_65.exe isn't.


noticed that.

fixed it by creating this script line and putting it in /etc/conf.d/local.start

/usr/local/bin/schedtool -B $(pidof FahCore_78.exe) $(pidof FahCore_65.exe)
_________________
we are microsoft, lower your firewalls and surrender your pc's. we will add your biological and technological distinctiveness to our own. your culture will adapt and service us. resistance is futile.
Back to top
View user's profile Send private message
pjv
Guru
Guru


Joined: 02 Jul 2003
Posts: 353
Location: Belgium

PostPosted: Thu Sep 09, 2004 7:17 pm    Post subject: Reply with quote

I use a pentium M (centrino). How can I run setiathome without my processor going higher than 600 MHz? I want this because it would be a stupid screensaver if it always pushed my processor into overload! Already tried nicing.

Thx,
pjv
Back to top
View user's profile Send private message
Veldrin
Veteran
Veteran


Joined: 27 Jul 2004
Posts: 1945
Location: Zurich, Switzerland

PostPosted: Mon Jun 06, 2005 9:54 am    Post subject: Reply with quote

Old Thread though....

Quote:
I use a pentium M (centrino). How can I run setiathome without my processor going higher than 600 MHz? I want this because it would be a stupid screensaver if it always pushed my processor into overload! Already tried nicing.

install a cpu scaling tool; I used speedfreq for some time, but it's no longer supported. I suggest cpufreqd, and the config goes pretty intuitive.

HTH
V.
Back to top
View user's profile Send private message
pjv
Guru
Guru


Joined: 02 Jul 2003
Posts: 353
Location: Belgium

PostPosted: Fri Jul 01, 2005 1:21 pm    Post subject: Reply with quote

Thx, but I'm already using speedfreq. The problem is that Seti@home drives it to the maximum clock frequency, while it should be a background screensaver that doesn't eat my battery power. How can I set it so that its load remains just below the threshold to go from 600 MHz to the higher clock frequency.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum