Perf
Installation perf
yum install -y perf
carried out:
perf top / grep " " * -r
Strace introduction and use
strace is for a diagnostic, analytical tools linux user mode process (pstrace, losf, gbd, pstrack, pt-pmp)
How many threads will start after start MySQL
strace /usr/local/mysql/bin/mysqld
# /usr/local/mysql/bin/mysqld --verbose --help | grep my.cnf
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
my.cnf, $MYSQL_TCP_PORT, /etc/services, built-in default
View worry about the system:
ps -T `pidof mysqld`
Use pstack
pstack `pidof mysql`
Recommended above MySQL5.7 version
select thread_id ,name from performanct_schema.threads
Strace use correct posture
The easiest to use
strace -T -t -o /tmp/strace.log CMD
strace -T -tt CMD 2>&1 | tee /tmp/strace.log
strace -T -tt -s 100 -o /tmp/strace.log CMD
strace -T -tt -s 100 -ff -o /tmp/strace.log CMD
strace -T -tt -s 100 -e trace = XXXX -o /tmp/strace.log CMD
strace parameters
-C count time performed for each system call, number, and frequency of errors
-d strace output debug information about the standard error
-f track approach by the child produced by fork call
-ff if provided -o filename, then track the results of all processes in the output to the appropriate filename.pid, pid is each
-r print out the relative time on every system call ,,
-T plus the time information before each line in the output
-Tt before each line in the output of adding time information microseconds
-T display time per call consumed, this parameter is particularly useful when troubleshooting performance issues
-v output all system calls, some calls about the environment variables, status, and other input and output calls due to the frequent use, the default is not output
-a column output location set return value, default is 40.
-e expr specify an expression that controls how the track
If the match conn_id and os_thread_id
MySQL 5.7 & 8.0
You can use sys.processlist and associate performance_schema.threads
select thd_id, conn_id, thread_os_id, name from sys.processlist a, performance_shcema.threads b where a.thd_id = b.thread_id and conn_id >0;
gdk attach xxxx tracking thread, this action will be to keep the process of the card
Use strace observation client SQL execution
ls /proc/`pidof mysqld`/fd -l
Performed with the server-side observation strace