Skip to content

Commit def20bd

Browse files
committed
debugging: slides: properly introduce flamegraphs and hotspot
Flamegraphs, while being a very valuable tool to get a graphical view of some profiling data, are only lightly covered, very early, and somehow in the middle of other concepts. Rework flamegraphs introduction to really introduce how to generate and read them: - move the flamegraph content in the system-wide profiling part, after having introduced the general perf commands, needed to generate flamegraph data - explain how to fetch the scripts and how to use them - add instructions about how to read a flamegraph, and a custom CPU flamegraph to illustrate it - add hotspot as an alternative/extension The only downside is that, now that flamegraphs are introduced later, we reach the heaptrack part without having introduced flamegraphs, but it may be fine to just announce that "we will cover flamegraphs more in details later" Fix #267 Signed-off-by: Alexis Lothoré <[email protected]>
1 parent 1d375eb commit def20bd

File tree

6 files changed

+102
-31
lines changed

6 files changed

+102
-31
lines changed

slides/debugging-application-profiling/debugging-application-profiling.tex

-31
Original file line numberDiff line numberDiff line change
@@ -50,37 +50,6 @@ \section{Application Profiling}
5050
\end{itemize}
5151
\end{frame}
5252

53-
\begin{frame}
54-
\frametitle{Visualizing data with flamegraphs}
55-
\begin{itemize}
56-
\item Visualization based on hierarchical stacks
57-
\item Allows to quickly find bottlenecks and explore the call stack
58-
\item Popularized by Brendan Gregg tools which allows to generate
59-
flamegraphs from \code{perf} results.
60-
\begin{itemize}
61-
\item Scripts to generate flamegraphs are available at
62-
\url{https://github.com/brendangregg/FlameGraph}
63-
\end{itemize}
64-
\end{itemize}
65-
\center \includegraphics[width=0.4\textwidth]{../slides/debugging-application-profiling/flamegraph.png}\\
66-
\tiny Image credits: \url{https://www.brendangregg.com/flamegraphs.html}
67-
\end{frame}
68-
69-
\begin{frame}[fragile]
70-
\frametitle{Going further with Flamegraphs}
71-
\begin{itemize}
72-
\item Really nice technical presentation from Brendan Gregg explaining
73-
the use of flamegraphs for various metrics.
74-
\begin{itemize}
75-
\item Video: \url{https://www.youtube.com/watch?v=D53T1Ejig1Q}
76-
\item Slides: \url{https://www.slideshare.net/brendangregg/usenix-atc-2017-visualizing-performance-with-flame-graphs}
77-
\end{itemize}
78-
\end{itemize}
79-
\begin{center}
80-
\center\includegraphics[height=0.5\textheight]{slides/debugging-application-profiling/flamegraph_atc20.png}
81-
\end{center}
82-
\end{frame}
83-
8453
\subsection{Memory profiling}
8554

8655
\begin{frame}
Binary file not shown.
Binary file not shown.

slides/debugging-system-wide-profiling/debugging-system-wide-profiling.tex

+102
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,108 @@ \subsection{perf}
387387
\end{block}
388388
\end{frame}
389389
390+
391+
\begin{frame}[fragile]
392+
\frametitle{Using a GUI to display perf data}
393+
\begin{itemize}
394+
\item \code{perf report} is the default way to display perf data,
395+
directly in the console
396+
\item There are also graphical tools to display perf data:
397+
\begin{itemize}
398+
\item
399+
\href{http://www.brendangregg.com/flamegraphs.html}{Flamegraphs}
400+
\begin{itemize}
401+
\item Visualization based on hierarchical stacks
402+
\item Allows to quickly find bottlenecks and explore the call stack
403+
\item Popularized by Brendan Gregg tools which allows to generate
404+
flamegraphs from \code{perf} results.
405+
\end{itemize}
406+
\item \href{https://github.com/KDAB/hotspot}{Hotspot} software
407+
\begin{itemize}
408+
\item Developed and maintained by KDAB
409+
\item A larger tool able to generate various types of
410+
visualizations from a \code{perf.data} file
411+
\item Can also perform the actual perf recording
412+
\end{itemize}
413+
\end{itemize}
414+
\end{itemize}
415+
\end{frame}
416+
417+
\begin{frame}[fragile]
418+
\frametitle{Visualizing data with flamegraphs (1/2)}
419+
\begin{itemize}
420+
\item Get the flamegraph scripts:
421+
\begin{block}{}
422+
\begin{minted}[fontsize=\small]{console}
423+
git clone https://github.com/brendangregg/FlameGraph fl
424+
\end{minted}
425+
\end{block}
426+
\item Capture data:
427+
\begin{block}{}
428+
\begin{minted}[fontsize=\small]{console}
429+
perf record -g -- sleep 30
430+
\end{minted}
431+
\end{block}
432+
\begin{itemize}
433+
\item The \code{-g} option records call stacks for each sample
434+
\end{itemize}
435+
\item Format the data:
436+
\begin{block}{}
437+
\begin{minted}[fontsize=\small]{console}
438+
perf script|./fl/stackcollapse-perf.pl > out.perf-folded
439+
\end{minted}
440+
\end{block}
441+
\begin{itemize}
442+
\item \code{stackcollapse-perf.pl} is part of the
443+
\href{https://github.com/brendangregg/FlameGraph}{Flamegraph
444+
repository}
445+
\item Other data sources are supported
446+
\end{itemize}
447+
\item Generate the Flamegraph:
448+
\begin{block}{}
449+
\begin{minted}[fontsize=\small]{console}
450+
./fl/flamegraph.pl out.perf-folded > flamegraph.svg
451+
\end{minted}
452+
\end{block}
453+
\item The flamegraph can then be opened in a web browser
454+
\end{itemize}
455+
\end{frame}
456+
457+
\begin{frame}[fragile]
458+
\frametitle{Visualizing data with flamegraphs (2/2)}
459+
\center
460+
\includegraphics[width=1.0\textwidth]{slides/debugging-system-wide-profiling/flamegraph.png}\\
461+
\begin{itemize}
462+
\item The plates width represents how often a function has been
463+
sampled
464+
\item The "spikes" height represents the call stacks depth
465+
\item Flamegraphs are interactive: clicking a plate will put focus on the
466+
corresponding callstack
467+
\item Colors can be tuned at flamegraph generation, for example to have
468+
a clear split between kernel and userspace functions
469+
\end{itemize}
470+
\end{frame}
471+
472+
\begin{frame}[fragile]
473+
\frametitle{Visualizing data with hotspot (1/2)}
474+
\begin{itemize}
475+
\item Designed to provide a frontend to perf data files
476+
\item Can generate flamegraphs on the fly, but not only:
477+
\begin{itemize}
478+
\item CPU/tasks timelines
479+
\item Interactive callstacks navigation
480+
\item Code disassembly
481+
\end{itemize}
482+
\item Configurable (eg: allows to set paths to find all needed debug
483+
informations)
484+
\end{itemize}
485+
\end{frame}
486+
487+
\begin{frame}[fragile]
488+
\frametitle{Visualizing data with hotspot (2/2)}
489+
\includegraphics[width=0.9\textwidth]{slides/debugging-system-wide-profiling/hotspot.png}\\
490+
\end{frame}
491+
390492
\subsection{ftrace and trace-cmd}
391493
392494
\begin{frame}
Loading
Loading

0 commit comments

Comments
 (0)