[25964] in Perl-Users-Digest
Perl-Users Digest, Issue: 8183 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 17 21:05:41 2005
Date: Fri, 17 Jun 2005 18:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 17 Jun 2005 Volume: 10 Number: 8183
Today's topics:
Re: Algorithm: spreading out jobs/events in time <1usa@llenroc.ude.invalid>
Re: Algorithm: spreading out jobs/events in time xhoster@gmail.com
Re: Module to match file names against a wildcard spec? <usenet@vyznev.invalid>
Re: Module to match file names against a wildcard spec? (Anno Siegel)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 17 Jun 2005 22:22:20 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Algorithm: spreading out jobs/events in time
Message-Id: <Xns9678BAE477C87asu1cornelledu@127.0.0.1>
pkent <pkent77tea@yahoo.com.tea> wrote in
news:pkent77tea-362F77.22462217062005@ptn-nntp-reader02.plus.net:
> But this is the hard part... what if some of my jobs have _different_
> frequencies? I want to work out how to stagger each job so that, over
> time, the work is still spread out on average and I minimize the
> number of times when jobs occur together.
...
> I've been thinking about frequencies, harmonics, phases, highest
> common factors, subsets of jobs with the highest common factor,
> differentials, local minima, ... but is this soluble?
Honestly, I do not know the answer. However, the solution (if one
exists) is going to be language independent. Maybe you could try
comp.programming?
Incidentally, the first hit returned by searching Google is
<URL:http://www.onjava.com/pub/a/onjava/2004/03/10/quartz.html>
and it might prove useful to you.
Here is a very naive approach:
1. Order jobs from shortest to longest.
2. Start the first job, set up a completion callback. The completion
callback just restarts the job.
3. Wait for a minute (or whatever granularity you want)
4. Start the next shortest job.
This is probably full of holes, and not optimal, but it easy easy to
implement and test.
On second thought, I know nothing, so don't listen to me :)
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: 17 Jun 2005 22:30:06 GMT
From: xhoster@gmail.com
Subject: Re: Algorithm: spreading out jobs/events in time
Message-Id: <20050617183006.865$Lx@newsreader.com>
pkent <pkent77tea@yahoo.com.tea> wrote:
> hi,
>
> I'm sure someone must have solved this problem before, but I've
> exhausted my searches of CPAN and the web - I bet there's a name for
> this algorithm but I don't know what.
>
> Imagine I have a program which has a number of independent, equally hard
> (i.e. same CPU usage) jobs to do.
Are these jobs not entirely CPU bottlenecked? I.e. is there any reason
to think that running more than on at a time will have better performance
than running them serially? Or are you already supposing serial execution?
> Each job should be run every 5
> minutes.
What if it takes more than 5 minutes of runtime to complete each job
once?
> What I want to do is spread those jobs out so that the "work"
> is as evenly distributed as possible.
>
> In that case it's obvious that I need to stagger each job by 5/n minutes
> to spread them out most evenly. Easy.
>
> But this is the hard part... what if some of my jobs have _different_
> frequencies? I want to work out how to stagger each job so that, over
> time, the work is still spread out on average and I minimize the number
> of times when jobs occur together.
If there is no benefit to parallel execution, and if the timings are
somewhat flexible, then you can just run the jobs serially. Keep track of
the last time each job was started, and then whenever one job finishes just
start whichever job is most overdue. If no jobs are overdue or nearly due,
sleep.
(Alternatively, you could run the job which is most overdue relative to
it's desired frequency, rather than in absolute time)
while (1) {
# how long till each job is due?
my @due = map time() - $last[$_] - $interval[$_], 0..$#jobs;
# find index of soonest due (or most overdue) job
my $soon = (sort {$due[$a]<=>due[$b]} 0..$#due)[0];
if ($due[$soon]> 5) {
sleep $due[$soon]-5; # Don't run a job too much before it's time
};
$last[$soon]=time();
system $jobs[$soon] and die;
}
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Sat, 18 Jun 2005 01:46:09 +0300
From: Ilmari Karonen <usenet@vyznev.invalid>
Subject: Re: Module to match file names against a wildcard spec?
Message-Id: <slrndb6klh.2vb.usenet@boojum.home.vyznev.net>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> kirjoitti 16.06.2005:
> Henry Law <news@lawshouse.org> wrote in comp.lang.perl.misc:
>>
>> I'm getting really tangled up trying to turn my exclude specifications
>> into regexes which I can then use to exclude relevant files; not only
>> am I not a very experienced Perl coder but the logic of the task turns
>> out to be quite complicated. For example
>
> A glob-to-regex translator wouldn't be very hard to write (I think).
It seems this has, in fact, been done already.
http://search.cpan.org/dist/Text-Glob/
--
Ilmari Karonen
To reply by e-mail, please replace ".invalid" with ".net" in address.
------------------------------
Date: 18 Jun 2005 00:48:55 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Module to match file names against a wildcard spec?
Message-Id: <d8vr1n$heb$1@mamenchi.zrz.TU-Berlin.DE>
Ilmari Karonen <usenet@vyznev.invalid> wrote in comp.lang.perl.misc:
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> kirjoitti 16.06.2005:
> > Henry Law <news@lawshouse.org> wrote in comp.lang.perl.misc:
> >>
> >> I'm getting really tangled up trying to turn my exclude specifications
> >> into regexes which I can then use to exclude relevant files; not only
> >> am I not a very experienced Perl coder but the logic of the task turns
> >> out to be quite complicated. For example
> >
> > A glob-to-regex translator wouldn't be very hard to write (I think).
>
> It seems this has, in fact, been done already.
>
> http://search.cpan.org/dist/Text-Glob/
Ah, yes. I haven't run it, but the doc looks good.
Anno
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 8183
***************************************