Questions tagged [perf]

Perf is a profiler tool for Linux 2.6+ based systems.

Perf is a profiling tool for Linux 2.6+ based systems that uses the perf_events kernel interface to provide a command-line interface to underlying hardware, software and kernel performance counters. It abstracts away differences in performance counters implemented across different CPU architectures, allowing consistency across different hardware.

See also the perf wiki.

1032 questions
16
votes
2 answers

Understanding the impact of lfence on a loop with two long dependency chains, for increasing lengths

I was playing with the code in this answer, slightly modifying it: BITS 64 GLOBAL _start SECTION .text _start: mov ecx, 1000000 .loop: ;T is a symbol defined with the CLI (-DT=...) TIMES T imul eax, eax lfence TIMES T imul edx, edx dec…
Margaret Bloom
  • 41,768
  • 5
  • 78
  • 124
15
votes
1 answer

Why does Perf and Papi give different values for L3 cache references and misses?

I am working on a project where we have to implement an algorithm that is proven in theory to be cache friendly. In simple terms, if N is the input and B is the number of elements that get transferred between the cache and the RAM every time we have…
jsguy
  • 2,069
  • 1
  • 25
  • 36
15
votes
1 answer

display only source code with Perf annotate

I'm using Perf to perform some profiling experiments. However, I would like to know results for a specific code region and for this case seeing the results (percentages) for each line of source code (C/C++ in this case) would ease the task. perf…
JohnTortugo
  • 6,356
  • 7
  • 36
  • 69
14
votes
1 answer

how to interpret perf iTLB-loads,iTLB-load-misses

I have a test case to observe perf iTLB-loads,iTLB-load-misses by perf stat -e dTLB-loads,dTLB-load-misses,iTLB-loads,iTLB-load-misses -p 22479 and get the output : Performance counter stats for process id '22479': 1,262,817 dTLB-loads…
barfatchen
  • 1,630
  • 2
  • 24
  • 48
14
votes
3 answers

is it possible to run linux perf tool inside docker container

I tried giving the below command from container and found the below issue, may be because of "-moby" kernel version. Can't we get a docker image without word "-moby" coming in linux kernel version. I tried installing linux perf tool on VM having…
Rupesh
  • 141
  • 1
  • 1
  • 5
14
votes
4 answers

How to profile time spent in memory access in C/C++ applications?

Total Time spent by a function in an application can be broadly divided in to two components: Time spent on actual computation (Tcomp) Time spent on memory accesses (Tmem) Typically profilers provide an estimate of the total time spent by a…
Imran
  • 642
  • 6
  • 25
13
votes
2 answers

why perf has such high context-switches?

I was trying to understand the linux perf, and found some really confusing behavior: I wrote a simple multi-threading example with one thread pinned to each core; each thread runs computation locally and does not communicate with each other (see…
xiaoming-qxm
  • 1,738
  • 14
  • 23
13
votes
1 answer

Perf shows mangled function names

I wanted to give perf a shot to profile some programs after I saw this talk from CppCon 2015. I downloaded the same Google benchmark library that the guy uses in the talk, compiled my program with the appropriate switches, linked it to it, then used…
notadam
  • 2,754
  • 2
  • 19
  • 35
12
votes
1 answer

Perf overcounting simple CPU-bound loop: mysterious kernel work?

I've been using Linux perf for some time to do application profiling. Usually the profiled application is fairly complex, so one tends to simply take the reported counter values at face value, as long as there isn't any gross discrepancy with what…
BeeOnRope
  • 60,350
  • 16
  • 207
  • 386
12
votes
2 answers

How do you get debugging symbols working in linux perf tool inside Docker containers?

I am using Docker containers based on the "ubuntu" tag and cannot get linux perf tool to display debugging symbols. Here is what I'm doing to demonstrate the problem. First I start a container, here with an interactive shell. $ docker run -t -i…
Nathan Whitehead
  • 1,942
  • 2
  • 16
  • 19
12
votes
3 answers

Is there a way to find performance of individual functions in a process using perf tool?

I am trying to get performance of individual functions within a process. How can I do it using perf tool? Is there any other tool for this? For example, let's say, main function calls functions A , B , C . I want to get performance of main function…
Bapi Sekh
  • 121
  • 1
  • 3
12
votes
3 answers

Measure page faults from a c program

I am comparing a few system calls where I read/write from/to memory. Is there any API defined to measure page faults (pages in/out) in C ? I found this library libperfstat.a but it is for AIX, I couldn't find anything for linux. Edit: I am aware of…
brokenfoot
  • 11,083
  • 10
  • 59
  • 80
11
votes
1 answer

Perf startup overhead: Why does a simple static executable which performs MOV + SYS_exit have so many stalled cycles (and instructions)?

I'm trying to understand how to measure performance and decided to write the very simple program: section .text global _start _start: mov rax, 60 syscall And I ran the program with perf stat ./bin The thing I was surprised by is the…
St.Antario
  • 26,175
  • 41
  • 130
  • 318
11
votes
0 answers

perf have no permission to collect stats

When I use perf to collect system stats, like this sudo perf record -a -g -F 997 -p pid sleep 30 then I got Error: You may not have permission to collect stats. Consider tweaking /proc/sys/kernel/perf_event_paranoid: -1 - Not paranoid at all 0 -…
bloomstar
  • 111
  • 1
  • 1
  • 5
11
votes
2 answers

Source line numbers in perf call graph?

I'm using perf record -a --call-graph dwarf -p XXX sleep 1 to record some function calls then perf report to view that data, however it would be very helpful if I could also see source line numbers to know exactly where each function call was made.…
QuantumBlack
  • 1,549
  • 11
  • 27
1 2
3
68 69