Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Thread alternative for multi-processing?

Reply
Thread Tools

Thread alternative for multi-processing?

 
 
howa
Guest
Posts: n/a
 
      04-16-2008
Sometimes, I want to take the advantage of multi-core processor, and
make the full use of my CPU time,

e.g. I have a function, which takes a file name as input, do some text
processing (e.g. CPU intensive), and save it back.

I don't want to use thread, as it need to recompile perl on all my
machines and I am not sure if it is stable enough to affect other
apps.

I don't mind to have a little overhead in using the fork mode (i.e.
multi-process). I want to know are there any recommended module for
my purpose?

For example, I am trying Parallel::ForkManager, POE::Wheel::Run, so
anyone want to share the experiences?


Thanks.
 
Reply With Quote
 
 
 
 
Peter Makholm
Guest
Posts: n/a
 
      04-16-2008
howa <(E-Mail Removed)> writes:

> For example, I am trying Parallel::ForkManager, POE::Wheel::Run, so
> anyone want to share the experiences?


I have used Parallel::ForkManager a lot with no problems, it just
works. I have never had the need to communicate enything more complex
than the exit code back to the parrent though.

//Makholm
 
Reply With Quote
 
 
 
 
nolo contendere
Guest
Posts: n/a
 
      04-16-2008
On Apr 16, 4:50*am, Peter Makholm <(E-Mail Removed)> wrote:
> howa <(E-Mail Removed)> writes:
> > For example, I am trying Parallel::ForkManager, POE::Wheel::Run, so
> > anyone want to share the experiences?

>
> I have used Parallel::ForkManager a lot with no problems, it just
> works. I have never had the need to communicate enything more complex
> than the exit code back to the parrent though.


I've found it useful to pass an $ident which i can use in the
run_on_finish callback to associate with the exit code.
 
Reply With Quote
 
Peter Makholm
Guest
Posts: n/a
 
      04-16-2008
nolo contendere <(E-Mail Removed)> writes:

>> I have used Parallel::ForkManager a lot with no problems, it just
>> works. I have never had the need to communicate enything more complex
>> than the exit code back to the parrent though.

>
> I've found it useful to pass an $ident which i can use in the
> run_on_finish callback to associate with the exit code.


Yes, but I consider this to be communication from the parrent on fork
time to the parrent on wait time. Even if the $ident is an reference
to something, the child can't change it for the parrent.

//Makholm
 
Reply With Quote
 
nolo contendere
Guest
Posts: n/a
 
      04-16-2008
On Apr 16, 11:10*am, Peter Makholm <(E-Mail Removed)> wrote:
> nolo contendere <(E-Mail Removed)> writes:
> >> I have used Parallel::ForkManager a lot with no problems, it just
> >> works. I have never had the need to communicate enything more complex
> >> than the exit code back to the parrent though.

>
> > I've found it useful to pass an $ident which i can use in the
> > run_on_finish callback to associate with the exit code.

>
> Yes, but I consider this to be communication from the parrent on fork
> time to the parrent on wait time. Even if the $ident is an reference
> to something, the child can't change it for the parrent.
>


True, perhaps I should have replied to the OP. I was simply sharing my
experience with Parallel::ForkManager, didn't mean to imply that the
$ident was a child->parent communication.
 
Reply With Quote
 
xhoster@gmail.com
Guest
Posts: n/a
 
      04-16-2008
howa <(E-Mail Removed)> wrote:
> Sometimes, I want to take the advantage of multi-core processor, and
> make the full use of my CPU time,
>
> e.g. I have a function, which takes a file name as input, do some text
> processing (e.g. CPU intensive), and save it back.


The saving it back might be a problem. Do the lines have to be saved
back in the same order they are originally present? With parallel,
it requires special efforts to make that happen.

>
> I don't want to use thread, as it need to recompile perl on all my
> machines and I am not sure if it is stable enough to affect other
> apps.
>
> I don't mind to have a little overhead in using the fork mode (i.e.
> multi-process). I want to know are there any recommended module for
> my purpose?
>
> For example, I am trying Parallel::ForkManager, POE::Wheel::Run, so
> anyone want to share the experiences?


In this case, I'd tend to role my own forking. I generally use
Parallel::ForkManager for when the number of processes I want run is
greater than the number I want to run simultaneously, which doesn't seem to
be the case for you. You certainly *can* use it in other cases, I just
don't see much need to. I've looked into POE::Wheel::Run a few times but
never got over the activation barrier to actually use it.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Inter-thread alternative to Boost message_queue Max C++ 2 07-29-2010 01:58 PM
Quicktime Alternative, RealPlayer Alternative & Media Player Classic John Capleton Computer Support 3 12-05-2005 07:41 AM
Terminating a thread from the main thread Charles A. Lackman ASP .Net 3 12-09-2004 02:12 PM
"Thread was being aborted" error from WebApp using Thread.Sleep. Stephen Miller ASP .Net 3 07-01-2004 11:50 PM
perl 5.8.2/3 - thread started by a thread pawo Perl 0 02-16-2004 01:18 PM



Advertisments