Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Things you need to know before programming Perl ithreads

by NetWallah (Canon)
on Aug 31, 2003 at 15:27 UTC ( #288032=note: print w/replies, xml ) Need Help??

in reply to Things you need to know before programming Perl ithreads

In the context of this discussion, it is worth repeating the thread usage discussion in "perldoc perlthrtut". I have emphasized the primary usage directive, which explains the "right" way to use threads with the current implementation (5.8).

Performance considerations
The main thing to bear in mind when comparing ithreads to other threading models is the fact that for each new thread created, a complete copy of all the variables and data of the parent thread has to be taken. Thus thread creation can be quite expensive, both in terms of memory usage and time spent in creation. The ideal way to reduce these costs is to have a relatively short number of long-lived threads, all created fairly early on - before the base thread has accumulated too much data. Of course, this may not always be possible, so compromises have to be made. However, after a thread has been created, its performance and extra memory usage should be little different than ordinary code.
Also note that under the current implementation, shared variables use a little more memory and are a little slower than ordinary variables.

  • Comment on Re: Things you need to know before programming Perl ithreads

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2021-10-27 09:36 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (91 votes). Check out past polls.