- Execute the
perf
command to check if it's installed; if not installed, then execute (on CentOS):sudo yum install perf
- View hot functions in real-time:
perf top --call-graph dwarf -p {PID}
, check if you can see the function stack of mysqld. Issues such as AHI(Adaptive Hash Index) are relatively easy to identify. - Generate a flame graph.
# If mysqld is running inside a container,
# then copy the mysqld binary file to the same execution path on the host machine.
docker cp {ContainerId}
# Find the process number of mysqld.
ps -ef | grep mysqld
# Sample for 40 seconds.
perf record -F 99 -p {pid} -g --call-graph dwarf -- sleep 40
# Convert the binary perf.data to text form.
perf script > out.perf
# Generate a flame graph.
# For the download of the flame graph tool, see the end of the document.
./FlameGraph-master/stackcollapse-perf.pl out.perf > out.folded
./FlameGraph-master/flamegraph.pl out.folded > mysqld.svg
Flame graph tools: FlameGraph-master.zip