[TLC] Client cache handling scripts

Status
Not open for further replies.

Hat Monster

Ars Legatus Legionis
47,680
Subscriptor
Okay, you've just managed to persuade your employer to allow you to run S@H on the workstations. But now you want to cache and there's no way in hell that you're going to get SETIDriver on the approved apps list and SETIQueue is plain out of the question.

Enter the script, it isn't an app so shouldn't need approval. Works on any Windows that can run the CLI client. For these to run, you should set up the client in five directories, edit the scripts to point to them, and set up the client with user details.

code:<HR>
Code:
rem .begin
rem unrem the above for continuous operation, be sure to run the refil script from time to time!

echo Running client 1
@C:\1\seti.exe -stop_after_process

echo Running client 2
@C:\2\seti.exe -stop_after_process

echo Running client 3
@C:\3\seti.exe -stop_after_process

echo Running client 4
@C:\4\seti.exe -stop_after_process

echo Running client 5
@C:\5\seti.exe -stop_after_process

echo Cache Empty! Please run the refill script!

rem goto begin
rem unrem the above for continuous operation.
The above will make sure your processors stay busy for a day or two. Perfect for scheduling overnight.

code:<HR>
Code:
echo Attempting to refresh client 1
@C:\1\seti.exe -stop_after_xfer

echo Attempting to refresh client 2
@C:\2\seti.exe -stop_after_xfer

echo Attempting to refresh client 3
@C:\3\seti.exe -stop_after_xfer

echo Attempting to refresh client 4
@C:\4\seti.exe -stop_after_xfer

echo Attempting to refresh client 5
@C:\5\seti.exe -stop_after_xfer

echo Cache refilled!
The above script should be used in conjunction with the first script, it will rebuild the cache and upload any results. It can be run while the first script is still running.
code:<HR>
Code:
.begin

echo Running client 1
@C:\1\seti.exe -stop_after_process

echo Processing complete. Attempting to refresh client 1
@C:\1\seti.exe -stop_after_xfer

echo Running client 2
@C:\2\seti.exe -stop_after_process

echo Processing complete. Attempting to refresh client 2
@C:\2\seti.exe -stop_after_xfer

echo Running client 3
@C:\3\seti.exe -stop_after_process

echo Processing complete. Attempting to refresh client 3
@C:\3\seti.exe -stop_after_xfer

echo Running client 4
@C:\4\seti.exe -stop_after_process

echo Processing complete. Attempting to refresh client 1
@C:\4\seti.exe -stop_after_xfer

echo Running client 5
@C:\5\seti.exe -stop_after_process

echo Processing complete. Attempting to refresh client 1
@C:\5\seti.exe -stop_after_xfer

goto begin

echo Some unholy error that shouldn't have happened but did anyway.
echo Please check the script and clients.
The above script will run forever if you let it. It will upload results (or attempt to) as soon as they're done, if it fails to upload it will move on to the next client and retry the upload the next time around. This script effectively works around S@H's one hour wait before retries and also maintains a local cache. It's virtually unstoppable except by long outages, in which case the script can easily be extended to hundreds of clients.

H@
 
There is one vital thing missing with that script!!!

You must find and implement a "sleep" process.

Otherwise, if SETI has an outage you will be a bad person endlessly and uselessly consuming SETI's bandwidth trying to get connections. In today's circumstances, nothing would be less polite and more harmful to the team (as well as being useless for yourself).

Somewhere, in the archives, I give both a short Java and Microsoft C program that implements the vital sleep process. Unfortunately, it isn't built into Windows.

Don't put up that script without it!

If you cache up several WU (no more than a day's worth nowadays), then having a ten minute delay before you loop back to the top will have an insignificant bearing on your crunch rate but provide an absolutely vital bit of added behavior when there is an outage.

At the least, you don't want to deal with the e-mail from the SETI folks if they have to track you down. This is a well-known enough situation that they actually have a note about it on their web site.
 
Here's the sleep program (practically a demo of the interface)

code:<HR>
Code:
#include <windows.h>
#include <winbase.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {

    int sleeptime = 10000; // default is 10 sec.

    if (argc>1) sleeptime=(atoi(argv[1])*1000);

    Sleep(sleeptime);

    return 0;
}

The Java version isn't much different:

code:<HR>
Code:
public class Sleep {

 public static final void main(String args[]) {

    int sleep_time= 10000;  // 10 sec default

    try {
     if (args.length>0) sleep_time = (Integer.parseInt(args[0]))*1000;

     Thread.currentThread().sleep(sleep_time);

    } catch (Exception e) { System.err.println("Error: "+e.toString());
           System.exit(1); };

 }


} // end Sleep

The "times one thousand" stuff is because the actual sleep interface is in milliseconds, but the "public" interfaces of Unix and other OS' sleep commands are in seconds.


Also, under the present circumstances, I would advocate sleep commands between individual upload/download attempts. Anywhere from 10 to maybe as much as 240 seconds. The idea being -- if SETI has a "spike" of activity, you don't want to be trying all of your downloads during that time and then lose out on getting any WU. A sleep command is, of course, vital to do this.

If you repeat the upload/download script in a loop, then you want a very long sleep command -- many hours -- between reloopings at the bottom of the loop. If you are only able to do 5 or 6 WU a day per machine (this is what a fast machine would do), then trying to return all answers from all directories even every half hour is ridiculous overkill. I'm doing fine with a cycle measured in multiple hours (that is, I attempt to fill my "cache" of WU once per directory per multiple hours). And, I have large SMPs involved in my version of this, not just one CPU.

I'm still experimenting with this, but I'm having good success with my very shallow caching, with multiple hours between ul/dl cycles in spite of intermittent outages. Basically, I strive for two WU per CPU and it seems to work well enough. I leave plenty of bandwidth and actual WU out there for my teammates. No point in having WU idle in my machine.

The main thing now is not to have too many WU "stacked up" because all that really happens then is that you relaunch SETI over and over and since there is work_unit.sah and no results.sah in the directory, nothing happens (no connection, but nothing good either). So, a long cycle means more crunch in the end.

Also, a shallower cache works well with intermittent outage and tight bandwidth. People have discovered of late that a deep cache means a lot of WU that you have as much trouble returning as you do have trouble getting new WU. So, I keep it shallow and don't abuse SETI's servers. Seems to be working fine.

[This message was edited by Larry Loen on March 05, 2002 at 22:52.]
 

ober

Ars Praetorian
553
Another thing you could do is use the start /B command to start a transmit script. This script would look at each folder for the file result.sah and attempt a CLI -stop_after_xfer command on that folder. The /B switch will hide the window so you don't have an additional window on the task bar. Transmitting clients use virtually no CPU and only about 4Mb of address space, most of which isn't actually allocated in real memory.

Mike Ober.
 

Hat Monster

Ars Legatus Legionis
47,680
Subscriptor
Larry, people can add sleep commands as necessary. I didn't want to since if I did (on the last script) then x seconds would be wasted whether the servers were borked or not. If I knew windows scripting better, I'd check to see if the work unit was downloaded and take it from there. Although I have used various recursive dir lists over entire hard drives to force a script to wait in the past...

I also distinctly remember one of your scripts from a few months ago that, in your own words, would hit the servers "something fierce", IIRC.

My interests are to get WUs and crunch them, ensuring my CPUs don't go idle. The interests of Berkeley or of various bandwidth preachers may vary. You're saying that large caches are not an aid, yet the guys at Berkeley are saying they are and are, in fact, advising people to use SetiQueue, SetiDriver, etc.

H@
 
I also distinctly remember one of your scripts from a few months ago that, in your own words, would hit the servers "something fierce", IIRC.

If I did (I don't think I ever did), I have long since repented. Moreover, the SETI administrators have long cautioned against looping without sleeping. That I certainly knew before I wrote my own scripts. If I put up a "sleepless" script, it was because Windows just plain lacks this elementary facility. A problem I have obviously rememdied.

My interests are to get WUs and crunch them, ensuring my CPUs don't go idle.

Well, in the abstract, no one argues with this. But, when (in detail) a particular strategy helps no one and hurts everyone, it gets to be some strange combination of silly and selfish. It is an "innumerate" argument in the long run (10 minutes per day is 0.0069 of a day) and one lacking in actual experience with these sorts of scripts in the bargain.

I am glad to see you advocating these things, but your comments betray a lack of actual experience. Since my situation fits your original premise exactly, I've done this stuff and I can tell you the "sleep" thing is not a nicety. If nothing else, you don't want to be a hog on your own local network, either. "Sleepless" scripts of this sort will look like bugs to anyone who is trying to fix their network at whatever point in the chain between you and Berkeley they see this behavior (when it is continuous due to dried up caches).

The interests of Berkeley or of various bandwidth preachers may vary.

In other words, the hell with everyone else, I'm getting mine. Problem is, it doesn't really work with even the 15,000 or so active users SETI has (or whatever the machine count really is).

I know. My position is not entirely based on an Olympian above-the-fray attitude. I've had my machines run dry. Flogging SETI continuously does not work when there's an outage, either absolute or (as they have been recently) "statistical" due to saturation. The sort of measured do-it-over-time approach I advocate is not only polite, it is optimal in a team setting and under actual conditions we see. It also keeps you out of trouble with your own network admins (a fate I have so far avoided, but might not if I did as you suggest). Most critically, it actually seems to be no worse that the most selfish approaches anyway in terms of actual success. In other words, there's no real trade-off between "getting mine" and "being polite," or at least none at the specific magnitudes and retry rates I'm suggesting.

Once thousands of machines are flogging SETI due to any kind of slowdown, even on a sleep cycle basis, then getting through is going to be very tough. One might think that flogging every couple of seconds helps, even on a "I'll get mine" basis, but it just doesn't seem to do any better than a more measured approach in terms of actually getting through.

Theory sometimes matters and sometimes doesn't. Once you get to a network on the scale of SETI's it turns out that theory matters. Theory says "don't flog continuously, it doesn't help you and only beggars your neighbor."

You're saying that large caches are not an aid, yet the guys at Berkeley are saying they are and are, in fact, advising people to use SetiQueue, SetiDriver, etc.

Sure, they are belatedly advocating these things. But, they are not advocating everyone cache up 55 days worth of work units just in case there's a short outage. Advocating the tool is not the same as advocating a particular caching strategy. They have, in fact, endorsed no particular caching strategy, at least not overtly. They have said that it would be nice for caching programs to concentrate on off-shift, which is a sort of oblique semi-endorsement of what I advocated (at least, that's how I read someone's reposting of what the SETI folks said). But, that's my ever-shifting memory and even I don't remember it as an absolute endorsement of what I suggested.

However, as far as I know, nothing they have said in public (that I have seen) contradicts what I have been advocating. I doubt very much if they would advocate deep caches in any event as it is not in their interest in any situation. But, I am advocating what I advocate from our self-interest, not theirs. I know well that our interest and theirs do not line up perfectly.

There's nothing magical here. Model what I advocate yourself -- you'll see it doesn't hurt the individual and certainly helps the team.

[This message was edited by Larry Loen on March 06, 2002 at 08:25.]
 
Status
Not open for further replies.