Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Score: Perl 1, Ruby 0

by Anonymous Monk
on Mar 28, 2007 at 17:28 UTC ( [id://607069]=note: print w/replies, xml ) Need Help??


in reply to Re: Score: Perl 1, Ruby 0
in thread Score: Perl 1, Ruby 0

t1 = Thread.new { output = []; cmd = IO.popen( "dir /s u:\\", 'r' ); while cmd.gets output.push $_ end Thread.current["output"] = output } ... t1.join got = t1["output"] got.each{|line| puts line}
This code doesn't give the intended results. I'm still limited as to how many threads I can kick off.

Replies are listed 'Best First'.
Re^3: Score: Perl 1, Ruby 0
by BrowserUk (Patriarch) on Mar 28, 2007 at 19:18 UTC
    This code doesn't give the intended results.

    Who's (and what) intended purpose? It certainly served my intended purpose--that of discovering the limit of concurrent threads runnable using the Perl executable when built with the default Win32 configration.

    I'm still limited as to how many threads I can kick off.
    1. Why are you doing this? Is your purpose to simply run lots of threads, or have you a Perl application that you believe would benefit from running >120 concurrent threads.

      If the former, the snippet was not intended to, and could not, bypass the inherent limitations of the Perl executable.

      If the latter, in most cases you should probably think again about your design. If you really believe that you have an application that does benefit from more than 120 concurrent iThreads, then see point 2.

    2. It is possible to modify a (copy of) a win32 Perl executable to allow more than 120 threads to run concurrently. See my post at Use more threads. for the how.

      That said, that post only addresses the how, not the why. To usefully make use of more than 120 concurrent iThreads requires much more than just changing the limit. It also requires that you adopt some very specific coding practices to avoid or work around other limitations inherent in the iThreads architecture.

      These practices are neither intuative, nor what would be readily recognised as standard Perl working practice. They are described, piecemeal, across a whole bunch of posts (by me and others, notably zentara,jdhedden & renodino) here at PM, but to my knowledge there is no one place here or elsewhere that brings all the details together in a comprehensive reference. In part, because I don't think that anyone has really done enough work in multi-cpu environments to have yet tied down what best working practice should be.

    If you still believe you have an application that would benefit from running large numbers of concurrent ithreads, if you were to post a description of that problem, you may well get further advise on implementing it. Along with advice on the possible alternatives to ithreads for achieving your goal.


    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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-16 04:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found