Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^2: Perl threading stability?

by guice (Scribe)
on Jul 25, 2005 at 17:59 UTC ( #477927=note: print w/replies, xml ) Need Help??

in reply to Re: Perl threading stability?
in thread Perl threading stability?

Now this part surpises me:
Shared data in perl's ithreads is very expensive, both in terms of speed and memory usage. A shared scalar variable usually has a copy in every thread that uses it, plus a separate shared copy. When you assign to a scalar, the thread's copy is updated, then that data is also copied to the hidden shared copy. When you read from a shared scalar, the data from the hidden shared copy is copied to the thread's one. Thus if you have N threads all accessing a long string variable, your memory usage will tend towards (N+1) times the length of the string.

I would have thought Perl use references for everything, not complete copies, making things much less memory and resource intensive...

Try to avoid having complex, deeply-nested shared data structures

Doh! One of the ideas was to use an XML::Simple object to store server data and each thread would update that object based on possible changes ... looks like I might have to keep with fork() with a slight restructure in how i would modify that main hash.

-- philip
We put the 'K' in kwality!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://477927]
[Corion]: *core
[Corion]: ** chore
[Corion]: So I guess I will simply implement the linear scan first and wait with more fancy stuff until it becomes a problem
[karlgoethebier]: Lady_Aleena: ++ for "The Man Crusher Everyday"
[karlgoethebier]: this mad my day
[karlgoethebier]: no typo
[marioroy]: At the Fransiscan monastery, got stuck up high in a tree from pruning and the chainsaw with large branch fell and broke the latter, but not me fortunately. Was stuck there for a while until a firetruck came by.
[Corion]: marioroy: So you live dangerously ...
[Lady_Aleena]: s/latter/ladder/; # ? marioroy
[karlgoethebier]: marioroy: Praise the Lord

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (12)
As of 2017-05-29 08:33 GMT
Find Nodes?
    Voting Booth?