I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2011-03-14 06:53:14.711938-07 by lowry76
Shared variables locked?
Hi, I'm new to perl-threads but have/want to use them for a very time-consuming problem. The script uses a large hash-ref with data the threads should work on. The hash just holds the data to work with but nothing is changed. Because I ran into memory probs when not sharing the hash I use the shared_clone() to share it and pass it to the different threads. What I experience now is that compared to the non-shared-option the performance drops to ~50%.
My first guess was that shared_clone somehow locks the shared variable as soon as one of the threads starts reading it because it's not declared read-only. But the source does not look like it.

Can someone explain the loss of performance? Should/could/do I have to declare everything read-only to overcome this?

Cheers,
lowry

Perl v5.8.8
threads::shared v1.36
OS: Ubuntu 4.2.4
Direct Responses: 13256 | Write a response