A client recently asked me to look into the availability of tools to help develop multithreaded C++ code, and having now spent some time doing just that, I thought the results might be worthy of a presentation at C&B.
The kinds of tools I investigated can be broadly broken down into correctness tools and performance tools. Correctness tools help identify errors in multithreaded code that can lead to incorrect behavior. They look for things like races, deadlocks, livelocks, and incorrect use of threading APIs, e.g., locking one mutex but unlocking another, locking or unlocking a nonrecursive mutex more than once, etc. Performance tools help identify issues that do or could prevent multithreaded code from scaling as well as it might. They look for things like false sharing, lock convoying, uneven work distribution across threads, etc.
I mostly limited my focus to learning about correctness tools, but even with that restricted goal I was surprised to find that the landscape is more varied than I’d expected. There are commercial tools as well as freeware and open source tools. Some are production-ready, others are still in research labs. Some are based on static analysis, some on dynamic analysis. Of the dynamic analysis tools, some give on-the-fly results, others display results only after the program being examined has stopped running. Among the tools that detect potential or actual data races, the approaches and algorithms vary considerably, as do their corresponding pros and cons. If you want to get an overview of your options, there’s a fair amount of information to absorb.
My research doesn’t make me an expert in these tools, it simply makes me somewhat informed. Furthermore, I haven’t even run any of these tools — I’ve simply read about them. Still, my thinking is that an overview of what’s available, how they do what they do, and the associated advantages and disadvantages could be useful, and it could also act as the foundation for ongoing informal discussions and experience reports. But maybe I’m deceiving myself. Maybe the topic isn’t as interesting or useful as I think it might be.
What do you think? Do you think an overview of existing tools to help detect correctness problems in multithreaded C++ code would be a valuable addition to C&B?