Knowledgebase:
Using perf to understand performance
29 June 2021 04:45 PM

Abstract

perf is a tool that can help analyze the performance of a process on Linux.

Discussion

Often, pstack is recommended as a way of understanding the behavior of MarkLogic Server. pstack works by pausing the MarkLogic process and printing out an execution stack trace; this effectively gives a point-in-time view of what the process is doing. When repeated over time, this gives a time-sliced view of the process.

Another tool for understanding performance is perf. perf works by sampling the process, rather than pausing it, and so is more lightweight than pstack, and it gives a statistical view of the process execution.

A typical use would be recording the activity for a minute or so when the CPU is high.

Installation

To install on RHEL/CentOS:

yum install perf

Use

To record and report the data (must be run as root/sudo):

 cd /tmp

then

 perf record -F 99 -ag -- sleep 60

This will take about one minute and write a file called perf.data in your working directory. Then, create a report as follows:

 perf report --header -I --stdio > `hostname -s`.`date -Is`.report 

This reads the perf.data and creates a readable report in the file nodeX, which can be submitted for analysis.  Please also run

 perf script > `hostname -s`.`date -Is`.script

and submit the nodeX.script file.  The file may be large but should compress well.

A quick way to find what calls are taking the most time is to run

 perf top

Note: All the steps outlined above need to be executed on the same MarkLogic host

See also

(7 vote(s))
Helpful
Not helpful

Comments (0)