Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
What version of threads are you using ? Have you installed the latest from CPAN (*many* fixes and features have been applied since Perl 5.8.5's core threads release).

That said, I'd suggest you revisit your architecture. Obviously, there are many pieces I'm not privy to, but your current code is very non-deterministic, and I'd consider it a bit dangerous to put into production. Have you considered combining the Parse and Process inside individual threads, with a lock around the output file, and creating a fixed size pool of threads executing the resulting method ? You'd have to pass the new sockets to the threads as fileno's and reconstitute them via fdopen(), but that's still likely to be faster than constantly spawning/destroying new threads, and certainly more manageable/debuggable. It may not solve your immediate issue, but I suspect you'll find the cause faster.

Interestingly, a recent use.perl.org journal pointed to some related threads links, esp. the unfortunately titled 'The Problem With Threads'. In brief, nondeterminism is bad, and in your case, possibly unsafe.

One more suggestion: try monitoring with Devel::STrace. I used it to diagnose a similar problem with a highly threaded app...turned out to be some unexpected behavior when the socket peer dropped the connection unexpectedly. (However, its also likely sensitive to your transient thread architecture).

One last hint: assuming you use a newer version of threads, you may want to adjust the thread stacksize (depending on the platform) to help reduce footprint.


Perl Contrarian & SQL fanboy

In reply to Re: CPU Leaking Threads by renodino
in thread CPU Leaking Threads by Trizor

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: (4)
As of 2024-04-23 18:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found