[Orca-users] Threads
Blair Zajac
blair at orcaware.com
Mon Aug 31 10:50:30 PDT 2009
Hudes, Dana wrote:
>
>> Blair Zajac [mailto:blair at orcaware.com]
>> I don't think we need threads for this. The main loop in Orca is
> single threaded, so when it goes to read from a data file, it'll use
>> use the Compress::Bzip2 instance for that file.
>
>> Plus, we probably don't want as many threads as there are hosts being
> monitored, that would easily kill a box.
>
> If the main loop is single-threaded
> 1) that would imply one bunzip2 process launched at a time and wait for
> the result. That is not in fact the case.
> If you look at the code it just keeps spawning bunzip2 processes until
> the spawn fails.
Right, but the bunzip2 processes block until the main thread reads them.
> 2) Single-threaded main loop misses an easy obvious parallelism.
>
> The optimal approach is not to launch a thread per host but to put work
> into a queue which is read by a pool of worker threads. The number of
> worker threads is configurable. This is how, for example, Apache2
> worker thread model works (of course most folks run apache2 in prefork
> mode ).
I suggest to break the work into two steps, the first is just switching to
Compress::Bzip2 using the main loop to read the files with a second step is to
have a configurable thread pool. Each of these would be separate commits.
Regards,
Blair
More information about the Orca-users
mailing list