DRD (Detector of Runtime Data races) is an alternative to helgrind for detecting data races in multithreaded code. Like helgrind, it instruments memory accesses to find races, but it uses a different detection algorithm that's sometimes faster or catches different patterns.
valgrind --tool=drd ./threaded_program
DRD and helgrind serve the same purpose (data race detection) but have different trade-offs. helgrind is more mature and widely used; DRD is sometimes faster on certain workloads. For most projects, use helgrind. If helgrind is too slow or misses races you suspect, try DRD.
When to use DRD instead of helgrind: 1. Performance: DRD is sometimes faster than helgrind on programs with many threads 2. Lock-free code: DRD has better support for atomic operations and lockless data structures 3. False positives: Different algorithm may report fewer (or more) false positives for your code
Both tools report data races where two threads access the same memory without synchronization. The output format is similar.
Lock-checking: Like helgrind, DRD checks for lock-ordering inconsistencies and can detect potential deadlocks:
valgrind --tool=drd --check-stack-var=yes ./program
--check-stack-var also checks for races on stack variables (less common but possible in shared memory scenarios).
Suppression: As with helgrind, library code may have benign races or custom synchronization that DRD doesn't understand. Use --suppressions files to ignore known issues:
valgrind --tool=drd --suppressions=drd.supp ./program
Choosing between helgrind and DRD: Start with helgrind (more documentation and community experience). If you hit performance issues or need different detection strategies, try DRD. For production testing, run both occasionally—they may catch different race conditions.
Performance comparison: Both DRD and helgrind add significant overhead (5-20x slowdown for multithreaded code). They're best used in test suites with simplified test cases, not on full production runs. On large MPI codes, extract single MPI ranks and test them locally.