4 ms·
> Could an unguarded TreeMap cause 3,200% utilization? I've seen the same thing with an undersynchronized java.util.HashMap. This would have been in like 2009,
by scottlamb 2y ago
> Could an unguarded TreeMap cause 3,200% utilization?
I've seen the same thing with an undersynchronized java.util.HashMap. This would have been in like 2009, but afaik it can still happen today. iirc HashMap uses chaining to resolve collisions; my guess was it introduced a cycle in the chain somehow, but I just got to work nuking the bad code from orbit [1] rather than digging in to verify.
I often interview folks on concurrency knowledge. If they think a data race is only slightly bad, I'm unimpressed, and this is an example of why.
[1] This undersynchronization was far from the only problem with that codebase.
- TYMorningCoffee 2y agoOh no I didn't know this can happen with HashMaps too! Something to do with the linked list they use for collisions?
- vineet_rc 2y ago[dead]
- scottlamb 2y agoThere's a dead comment replying to yours with this link: https://mailinator.blogspot.com/2009/06/beautiful-race-condition.html https://mailinator.blogspot.com/2009/06/beautiful-race-condi... ...which I don't think I've ever seen before, but nicely explains the problem I saw, and coincidentally is from the same year!