Questions tagged [perf]

Performance analyzing tool in Linux, also called perf_events; originally "Performance Counters for Linux", PCL (not to confuse with "Printer Command Language" nor "Point Cloud Library").

From perf.wiki.kernel.org:

perf began as a tool for using the performance counters subsystem in Linux, and has had various enhancements to add tracing capabilities.

Performance counters are CPU hardware registers that count hardware events such as instructions executed, cache-misses suffered, or branches mispredicted. They form a basis for profiling applications to trace dynamic control flow and identify hotspots. perf provides rich generalized abstractions over hardware specific capabilities. Among others, it provides per task, per CPU and per-workload counters, sampling on top of these and source code event annotation.

Perf is natively supported in popular Linux distributions, including Red Hat Enterprise Linux and Debian (linux-tools package).


perf is used with several subcommands (short, non-exhaustive list):

  • stat: runs a command and gather performance counter statistics;
  • top: displays top-like dynamic view of hottest functions;
  • record: runs a command and records its profile into perf.data;
  • report: analyzes file generated by perf record; can generate flat, or graph profile;
  • annotate: reads perf.data (created by perf record) and displays annotated code.

Example output of sudo perf stat tree /proc:

# started on Mon Aug 15 23:52:19 2016


 Performance counter stats for 'tree /proc':

       3929,205496 task-clock                #    0,681 CPUs utilized          
             79325 context-switches          #    0,020 M/sec                  
                33 CPU-migrations            #    0,000 M/sec                  
               273 page-faults               #    0,000 M/sec                  
        5745409809 cycles                    #    1,462 GHz                     [49,96%]
   <not supported> stalled-cycles-frontend 
   <not supported> stalled-cycles-backend  
        1465748665 instructions              #    0,26  insns per cycle         [74,84%]
         329884771 branches                  #   83,957 M/sec                   [75,30%]
          36420135 branch-misses             #   11,04% of all branches         [74,74%]

       5,765637169 seconds time elapsed
10 questions
59
votes
1 answer

Run perf without root-rights

I'm running debian testing with the 4.1 kernel and version 4.1 of the perf tool. In this version they seem to have added some sort of protection to keep normal users from collecting data from that tool. So running perf as normal user will give this…
kain88
  • 735
  • 1
  • 6
  • 6
8
votes
1 answer

What is exactly shown by "perf" as page-faults?

I want to count the number of disk accesses during a complete run of my script. My bash script runs 2 other executable files locally and 2 other executable files remotely. Something like this (those executable files may access other tools…
Dark
  • 183
5
votes
1 answer

Read and parse perf.data

I am recording a performance counters frm linux using the command perf record. I want to use the result perf.data as an input to other programming apps. Do you know how shall I read and parse the data in perf.data?
5
votes
2 answers

installing perf on RedHat

I read about perf tool and I was interested in using in my RedHat. On Ubuntu it is enough to call sudo apt-get install linux-tools-2.6.38-11. What about RED HAT? I tried both: yum install linux-tools yum install perf ...but it doesn't work. Do you…
4
votes
1 answer

perf cannot get cache-misses for Linux VM on VMware ESX

I interested on measuring CPU cache-misses parameter and came across this tool called perf. I followed the wiki and able to get the cache-misses when this command is run on physical machine [root@supermicro ~]# perf stat -e cache-misses dd…
cheng wee
  • 143
4
votes
1 answer

Unable to change kernel.perf_event_paranoid

I am trying to collect some data using perf, but whenever I try perf, I get the "You may not have permission to collect stats.", error. I have tried changing the /proc/sys/kernel/perf_event_paranoid value to -1; but each time it miraculously resets…
3
votes
1 answer

Permission to use perf timechart

I am learning to use perf profiling tool on my Ubuntu 18.04.3 LTS. I know by using perf timechart you can visualize your system behavior during a workload. I tried that with my parallel program: perf timechart record mpirun -np 4 main Then I got…
Shiqi
  • 133
1
vote
0 answers

Does perf work on Red Hat 6.7?

My company is stuck on Red Hat Enterprise Linux 6.7. Running perf record ls as non-root results in an error: "Perf session creation failed." $ cat /proc/sys/kernel/perf_event_paranoid 1 $ uname -r 2.6.32-573.51.1.e16.x86_64 It works on Redhat 6.4.…
projectshave
  • 404
  • 1
  • 4
  • 11
1
vote
1 answer

Save "perf stat" output to a file without also saving the executed command's output

I'm running perf stat on the command ./start-server.sh -f server-config.xml: perf stat -e cache-misses ./start-server.sh -f server-config.xml I'd like to save the perf results to a file e.g. by appending &>out.txt to the command, however if I write…
0
votes
1 answer

nft_pipapo_avx2_scratch_index shows up on all my perf recordings

I'm investigating a performance issue on my Ubuntu 22.04.2 LTS machine. I take the following steps: sudo perf record -g -F max -s --call-graph dwarf -e cycles -e sched:sched_switch --switch-events --sample-cpu Then open the recording with sudo…