Using perf to understand performance
27 April 2017 06:17 PM
perf is a tool that can help analyze the performance of a process on Linux.
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.
An typical use would be recording the activity for a minute or so when the CPU is high.
To install on RHEL/CentOS:
To record and report the data (must be run as root/sudo):
This will take about one minute and write a file called perf.data in your working directory. Then, create a report as follows:
This reads the perf.data and creates a readable report in the file nodeX, which can be submitted for analysis. Please also run
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