in reply to Re^7: Avoid Locking Entire Hashes
in thread Avoid Locking Entire Hashes

demonstrate the idea that there is no advantage to using a mirrored data structure

Can't agree with you enough! I think your solution is quite elegant... although now we are back to locking the entire hash structure, albeit briefly from time to time...

Replies are listed 'Best First'.
Re^9: Avoid Locking Entire Hashes
by BrowserUk (Patriarch) on Jun 15, 2011 at 22:25 UTC
    although now we are back to locking the entire hash structure

    There is no choice in that when you are modifying the hash itself (by adding a new key). This will periodically cause the entire hash to be re-built from scratch, whenever the number of keys moves above the current fill threshold.

    Of course, if you pre-populate the hash and know that your trheads will never add new keys, then you can discount that branch of the if statement.

    However, have you not followed this branch of this thread?

    I showed there that in practice, locking the entire thread in the normal way works out to be more efficient -- up to 3 times more efficient -- than locking shared scalars within it. Locking shared scalars is an interesting, but ultimately futile tactic.


    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".
    In the absence of evidence, opinion is indistinguishable from prejudice.