Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

This probably won't affect the outcome of your tests, which seem backward to me, but without seeing what you are doing in locateSysHost_Parallel() it's not really possible to comment on what might or might not be the causes of the symptoms you are seeing beyond liz's observation about your second example serialising the threads, but this line from your first snippet:

(threads->list)[0]->join while threads->list;

is a horribly inefficient way to do things.

The first call to threads->list walks a linked list, constructing an object for each thread, expands the stack to accomodate it, and then pushes it on. It the returns to your code, where you promptly discard all but the first of them and call join on it.

The second call repeats the process of walking the linked list, but because of the scalar context, skips building the list and just accumulates a count and returns it to you. Which you then promptly discard by turning the count into a boolean.

You then repeat the above two steps for each thread running. That's is a O(2n!) (factorial) O(n*(n-1)) process where n is the number of threads. The following is simply O(n).

$_->join for threads->list;
and the scripts did not even get off the ground. We had our first print statement execute, then the threads went into lala land.

"did not get off the ground" and "lala land" are not very useful descriptions for attempting to diagnose a problem from :). A cut down script that demonstrates the problem would be much more useful.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: perl threads and dual core hyper-threading by BrowserUk
in thread perl threads and dual core hyper-threading by JFarr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found