Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Multithreading How do I share hash of hash of arrays

by sundialsvc4 (Abbot)
on Jan 23, 2015 at 14:02 UTC ( #1114287=note: print w/replies, xml ) Need Help??


in reply to Multithreading How do I share hash of hash of arrays

Also, seriously consider your “philosophical approach” here.   If this is a shared data structure that all of the threads must constantly access, then it could have the effect of serializing their execution in a way that effectively destroys the value of running multiple threads in the first place.

So, I shall graciously presume, instead, that what you have posted here is just an edited example ... that the threads actually spend most of their time doing something else, say, something I/O-related.   “Something else” that, in fact, consumes most of their respective wall-time, such that the time spent managing a shared data structure (once you get the example to compile and run, as BrowserUK correctly insisted) is just an insignificant step for which each lock attempt will most likely proceed without delay.

Multithreading is a fine strategy for overlapping I/O operations.   That’s essentially what it’s for.   But it has very limited use in CPU-intensive activities, and the necessary locking of shared data structures can utterly wipe that out, resulting in tasks that are slower than they otherwise might be.   Your example suggests to be one of those cases.

  • Comment on Re: Multithreading How do I share hash of hash of arrays

Replies are listed 'Best First'.
Re^2: Multithreading How do I share hash of hash of arrays
by BrowserUk (Pope) on Jan 23, 2015 at 14:07 UTC
    But it has very limited use in CPU-intensive activities,

    Utter garbage! (You just can't help yourself can you.)

    If I have a cpu-bound process that takes 1 hour; and I can spread that processing across 4 cpus, I can cut that runtime to 15 minutes.

    Just because data is shared; it doesn't mean it has to be locked. If only reads are performed no locking is necessary.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
    In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1114287]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2019-12-16 09:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?