in reply to Use thread with good care, but definitely keep using it

pg, you point to the huge cost of threads, but you don't point out what platform you're on. There's little agreement exactly what a thread is, and how expensive it should be, between platforms. Interestingly, the way I hear it, the closer a thread is to a new process, the /cheaper/ it tends to be. Then again, I've done very little thread programming, and have real access to only win32 and linux/x86.


Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

  • Comment on Re: Use thread with good care, but definitely keep using it

Replies are listed 'Best First'.
Re: Re: Use thread with good care, but definitely keep using it
by pg (Canon) on Mar 14, 2003 at 02:23 UTC
    Yes, the results would be different on different platforms, especialy for something like thread. As you pointed out, the thread implementations are so different on different platforms.

    Even on similar platforms, with a different configuration, the results are so different. I tried:
    1. windows 2k, with a high configuration (not sure about the exact numbers, I am at home now, and that one is at my company). After created 230 threads, the first script exited without error or warning, but quited.
    2. with this win98 at home, low configuration - 32m memory, it quited after 30 threads being created.
    On windows, I would expect the setting of virtual memory might alter the results.

    I think lots of people probably want to see results on other platforms, as future reference. I have access to unix, but it only has 5.6.1 installed, so useless in this case.

      WinXP corp (pro), 640MB RAM, AS 5.8.0 (build 804) dies after approx 333 threads, trying to write to memory at virtual address 4 -- clearly a bug. At that point, I'm 540 MB into swap, going down to 405MB after hitting "OK" to the debug or die dialog box (a dfferance of 135MB, but that doesn't neccessarly mean all that much), and the threads took an average of 1/30s to create (I modified your code slightly).

      BTW, anybody know if I should perlbug for this, or is this likely to be unrecognizably changed in bleadperl anyway?


      Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).