in reply to Re^8: Avoid Locking Entire Hashes
in thread Avoid Locking Entire Hashes
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.
|
|---|