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?
Scott
July 24, 2010 at 7:11 pm
IMO, any discussion aimed at helping people produce better, faster, stronger multi-threaded code cannot possibly be a waste.
July 25, 2010 at 5:06 am
The topic sounds interesting but without having used the tools would it be anything more than repeating what their authors claimed? When you get into this level of complexity it seems very common for tools to promise more than they can deliver.
July 25, 2010 at 11:05 am
Your concern is legitimate. Without practical experience with the tools, I will not be able to give advice on the size of codebases they can effectively handle, how well they handle “real” code, how quickly or (more likely) how slowly they run, etc. My hope is that other people at C&B can contribute some of this information.
At the same time, I think it’s important to bear in mind that the available tools are both numerous and varied. I’ve got 19 tools on my list, and that doesn’t include research efforts. Many tools are OS-specific, e.g., Jinx requires 64-bit Windows, Thread Validator requires 32-bit Windows, two of the three Valgrind-based tools (DRD and Helgrind) appear to require Linux, BSD, or MacOS. Trying to acquire meaningful experience with even the majority of the available tools would be a significant undertaking.