Linux perf-tools are great for finding hotspots in CPU cycles and optimizing those hotspots. But once some parts are parallelized it becomes difficult to spot the sequential par
Oracle's Developer Studio Performance Analyzer might do exactly what you're looking for. (Were you running on Solaris, I know it would do exactly what you're looking for, but I've never used it on Linux, and I don't have access right now to a Linux system suitable to try it on).
This is a screenshot of a multithreaded IO test program, running on an x86 Solaris 11 system:
Note that you can see the call stack of every thread along with seeing exactly how the threads interact - in the posted example, you can see where the threads that actually perform the IO start, and you can see each of the threads as they perform.
This is a view that shows exactly where thread 2 is at the highlighted moment:
This view has synchronization event view enabled, showing that thread 2 is stuck in a sem_wait
call for the highlighted period. Note the additional rows of graphical data, showing the synchronization events (sem_wait()
, pthread_cond_wait()
, pthread_mutex_lock()
etc):
Other views include a call tree:
a thread overview (not very useful with only a handful of threads, but likely very useful if you have hundreds or more
and a view showing function CPU utilization
And you can see how much time is spent on each line of code:
Unsurprisingly, a process that's writing a large file to test IO performance spent almost all its time in the write()
function.
The full Oracle brief is at https://www.oracle.com/technetwork/server-storage/solarisstudio/documentation/o11-151-perf-analyzer-brief-1405338.pdf
Quick usage overview:
collect
utility. See https://docs.oracle.com/cd/E77782_01/html/E77798/afadm.html#scrolltocanalyzer
GUI to analyze the data collected above.