Skip to content

Profiling concurrent programs

Category: Testing and tools · Status: stub · Lessons: chapter 09, Testing and tools (planned)

One line: Measuring where the time goes when many threads run — waiting for locks, waiting to be scheduled, and bouncing cache lines — and not only which functions are hot.

Also called: performance tuning, contention profiling, mutex profile.

How it connects

In each language

Go runtime/pprof has block and mutex profiles beside the CPU profile
Java JDK Flight Recorder ↗ records events such as lock contention from a running JVM
The operating system perf samples CPU time across every thread and the kernel

Where to read more

  • In the books: Java Concurrency in Practice, Brian Goetz, Tim Peierls, Joshua Bloch, Joseph Bowbeer, David Holmes, Doug Lea — ch. 11, 'Performance and Scalability'
  • In the books: Concurrent Programming on Windows, Joe Duffy — ch. 14, 'Performance and Scalability'
  • In the books: C++ Concurrency in Action, Anthony Williams — ch. 8, 'Designing concurrent code' → 'Factors affecting the performance of concurrent code'
  • In the books: Parallel and Concurrent Programming in Haskell, Simon Marlow — ch. 15, 'Debugging, Tuning, and Interfacing with Foreign Code'
  • In the books: asyncio Recipes, Mohamed Mustapha Tahrioui — ch. 8, 'Improving Asyncio Applications' → 'Profiling Asyncio Applications'
  • In the books: Erlang and OTP in Action, Martin Logan, Eric Merritt, Richard Carlsson — ch. 14, 'Optimization and Performance' → '– How to approach performance tuning'