Profiling with perf

From PostgreSQL wiki

Revision as of 21:50, 19 May 2012 by Boshomi (Talk | contribs)

Jump to: navigation, search

perf is a utility set added to Linux kernel 2.6.31. A quick example showing what perf output looks like is at Using Performance Counters for Linux.

Start/stop profiling

To profile the system for a specific length of time, for example 60 seconds:

 perf record -a -g -s sleep 60

To profile the system for the duration of a command:

 perf record -a -g -s -- pg_ctl -D pgdata start

To profile in real time:

 perf top

By default this will generate a perf.data file in the current working directory.

Analysis:

By default perf will look for perf.data in the current working directory.

 perf report -n

Annotated source code:

 perf annotate -l -P

Trace output:

 perf script -L

Availability

The perf tool is available on recent Linux distributions such as:

  • RedHat Linux Enterprise 6
  • Debian Squeeze: add the linux-tools package.

It may be built and installed from the linux source code in the tools/perf subdirectory.

Resources

Personal tools