Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do the perf record choices of LBR vs DWARF vs fp do?

Tags:

linux

perf

When I use the perf record on my code, I find three choices for the --call-graph option: lbr (last branch record), dwarf and fp.

What is difference between these?

like image 315
The flash Avatar asked Aug 09 '19 12:08

The flash


People also ask

What does perf record do?

perf record is used to sample events. Display a report that was previously created with perf record . Display a report file and an annotated version of the executed code. If debug symbols are installed, you will also see the source code displayed.

What is perf report?

perf report is able to auto-detect whether a perf. data file contains branch stacks and it will automatically switch to the branch view mode, unless --no-branch-stack is used. --branch-history Add the addresses of sampled taken branches to the callstack. This allows to examine the path the program took to each sample.

What is perf tool in Linux?

The perf command is used as a primary interface to the Linux kernel performance monitoring capabilities and can record CPU performance counters and trace points.


1 Answers

The option --call-graph refers to the collection of call graphs / call chains, i.e. the function stack for a sample.

The default, fp, uses frame pointers. This is very efficient but can be unreliable, particularly for optimized code. By explicitly using -fno-omit-frame-pointer, you can ensure that this is available for your code. Nevertheless, the result for libraries may vary.

With dwarf, perf actually collects and stores a part of the stack memory itself and unwinds it with post-processing. This can be very resource consuming and may have limited stack depth. The default stack memory chunk is 8 kiB, but can be configured.

lbr stands for last branch records. This is a hardware mechanism support by Intel CPUs. This will probably offer the best performance at the cost of portability. lbr is also limited to userspace functions.

like image 59
Zulan Avatar answered Sep 20 '22 06:09

Zulan