My (limited) experience with perl threads suggests that creating threads is a quite expensive operation where you also have to be careful about the amount of objects that get copied from the parent to the new thread.
What I did to get around this issue is to use a very limited main thread (basically, only load the modules you want to use, if that), then start all the threads you're going to need (depending on usage, I use 1 worker thread for each CPU, but if your process is disk-bound you may want more)
Then possibly load more stuff into the main thread and do all communication between the main and worker threads using Thread::Queue, or a few other shared objects.
Trying to share a load of nested objects will probably result in a lot of overhead.
In any case: try to limit the number of threads you create and join - re-use as many as possible (i.e. all of them). That way, you can get quite stable memory usage.
update: also, you may want to get the latest stable perl (5.8.8), but at least you'll want the latest versions of threads and threads::shared from CPAN.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.