threads::shared variables are *very* slow; you should share little, and access it not a lot.
The implementation essentially does a similar thing to tieing
(except that it's implemented in XS rather than perl); so
my %hash : shared;
...
$x = $hash{foo};
is a bit like
sub threads::shared::FETCH {
lock $Some:Global:lock_var;
return $Some::Shared::Space::hash{$_[0]};
}
my %hash;
tie %hash, 'threads::shared';
...
Note that each thread has its own copy of the 'tied' hash;
accessing it causes a global lock to be set, then an entry from the 'real' hash is copied to that thread.
Dave.