Hi,

On Jun 2, 2012, at 10:10 AM, Alexander Burger wrote:
> 
> 
> Having said this, I see that your test program doesn't operate on a
> database at all. Calling the C compiler in parallel tasks _does_ make
> sense. Then we talk about something completely different.

It was just an example. I'll have a database recording all the dependencies for 
each target.

> 
>> In that case I would need something like the following to be able to
>> invoke the shell commands and update the database with the results.
> 
> This would indeed make sense, if the shell commands induce a heavy load.

It does, say we have to invoke in the order of 10000 gcc commands. My toy 
application is a 'make' replacement.


> 
>> I don't like it, too convoluted for my taste. Any suggestion on how to
>> improve the performance/style? Perhaps a different approach would be
>> better?
> 
> Yes, I think so too. If I understand you right, you want to call a
> number of shell commands (in a batch list), and then store the results
> in a database. If so, you could use something like that:

Not exactly, I would prefer not to compose that list in advance. Would be good 
to be able to keep queueing commands while previous commands are running.
My guess is that deciding what to execute next will be time-consuming, as soon 
as it can be determined that a target is ready for execution its command should 
be queued.


> 
>   (de processJobs (CPUs Batch)
>      (let Slots (need CPUs "free")
>         (for Exe Batch
>            (let Pos
>               (wait NIL
>                  (seek
>                     '((Pos)
>                        (cond
>                           ((== "free" (car Pos))  # Found a free slot
>                              (set Pos "busy") )
>                           ((n== "busy" (car Pos)) # Found a result
>                              (msg (car Pos))      # Instead of 'msg': Store 
> result in DB
>                              (set Pos "busy") ) ) )
>                     Slots ) )
>               (later Pos (eval Exe)) ) ) ) )


I guess an additional step is needed that performs the equivalent of my 
"waitJobs":


(bench
   (processJobs 2 (mapcar '((X) (list '* X X)) (range 1 10))))
1
4
9
16
25
36
49
64
0.006 sec

No result for 8 and 9.

> 
> I didn't completely analyze your code. Just a warning about an error:
> 
>> (de "completeJob" ("Pos")
>>   (let (cdar "Pos")
>>      (let RESULT (caar "Pos")
>>         (eval (caddar "Pos")) ) )
> 
> The second line redefines the function 'cdar'. Is that intended?

Of course not :-)
It should read something like:
(bind (cadar "Pos") ...

Each slot contains (<result> <environment> <expression>), and that line tries 
to restore the environment of the instant when the command was queued, so that 
it restores all the bound variables before evaluating the expression.

Time to experiment a bit more. Thanks.

--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to