<?xml version="1.0" encoding="windows-1252"?>
<node id="288032" title="Re: Things you need to know before programming Perl ithreads" created="2003-08-31 11:27:16" updated="2005-07-07 15:04:59">
<type id="11">
note</type>
<author id="159887">
NetWallah</author>
<data>
<field name="doctext">
In the context of this discussion, it is worth repeating the thread usage discussion in &lt;i&gt;"perldoc perlthrtut"&lt;/i&gt;. I have emphasized the primary usage directive, which explains the "right" way to use threads with the current implementation (5.8).
&lt;p&gt;
&lt;b&gt;Performance considerations&lt;/b&gt;
&lt;br&gt;&lt;i&gt;
    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. &lt;font color='red'&gt;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. &lt;/font&gt;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.
&lt;br&gt;
    Also note that under the current implementation, shared variables use a
    little more memory and are a little slower than ordinary variables.&lt;/i&gt;
</field>
<field name="root_node">
288022</field>
<field name="parent_node">
288022</field>
</data>
</node>
