Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: Fork vs pThreads

by BrowserUk (Patriarch)
on Oct 21, 2013 at 11:05 UTC ( [id://1059098]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Fork vs pThreads
in thread Fork vs pThreads

And also the time it took from one block of 50 to other block of 50 and it was the same time as the longer one.

Of course. How could it be otherwise?

If you draw 10 parallel lines of different lengths:

--------------- ------ ---------------- ---- - ----------- -------- ------ -------------- -----

Is there any way to make the overall width less than the longest line?

Same thing.

As an aside, but entirely relevant; running 50 tasks concurrently on 4 cpus will take longer than running those same 50 tasks; but only 4 at any given time.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^4: Fork vs pThreads
by ThelmaJay (Novice) on Oct 21, 2013 at 13:46 UTC
    Sorry, I'm new to this. I don't understand why 50 tasks concurrently will take longer than running packs of 4.

      Change your code to:

      my $pm = Parallel::ForkManager->new(4); my $i = 0; while(i<50){ $pm->start and next; processStream($stream); $i++; $pm->finish; # do the exit in the child process } $pm->wait_all_children();

      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Thank you for spending time with me :).
      No packs. Just run 4 tasks, if one ends, start another one.
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
        How do I run those tasks? I fork 4 separately? Could you give me an example?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1059098]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-03-28 08:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found