by moregrist · 3y ago · 0 comments
Please protect your STL data structures with a mutex. Please keep your thread communications sane. There’s no reason to think through why one is more prone to explosion than another; any conclusions you draw are at best only relevant to your current compiler and STL implementation, and maybe only during some phases of the moon.
Seems reasonable to me. It's an interesting question even if any given answer is only valid under narrow conditions.
Have you ever wondered what’s up with the CF_SYLK and CF_DIF clipboard formats? [0]
Or why did the message on the Start menu change from Start to Ship It! for one build? [1]
Or how about filling in some gaps in the story of Space Cadet Pinball on 64-bit Windows [2]
[0] https://devblogs.microsoft.com/oldnewthing/20200226-00/?p=10...
[1] https://devblogs.microsoft.com/oldnewthing/20200505-00/?p=10...
[2] https://devblogs.microsoft.com/oldnewthing/20220106-00/?p=10...
Look at this from the point of code analysis - if "a bit more thread-safe" map is used - you have less chances to detect the problem in local testing & and may be surprised in prod. And, you may be even more surprised when switching to unordered map.
Usually, any big app has a huge tail of very rare crashes that nobody has time to fix, ever. Those rare crashes are indistinguishable from some system/hardware related faults (system OOM, system trying to kill an app, battery dying, bit flipping due to radiation/faulty silicon). And that's the point - if you are planning to change map to unordered map - look at the crashes list around map invocations and try to understand, if any of them are due to multithreading and not system/hw...
Asking and answering "why" is an important educational process. I've met other developers like you, and quite frankly they've always been mediocre to abysmal in their work, especially when debugging, because they've almost completely lost the ability to reason and hypothesise.
It isn't an official Microsoft publication.