Precautions
- In the running phase after instrumentation, a sampling file can be generated only after a program ends normally. If you run the kill -9 command, the sampling file cannot be generated normally.
- If the program cannot exit normally, try the following method to generate a profile (MySQL is used as an example):
1 2 3 4 5 6
echo "set height 0" > gdb.cmd echo "handle SIGPIPE SIGUSR1 SIGUSR2 SIG36 noprint nostop" >> gdb.cmd echo "call (void)__llvm_profile_write_file()" >> gdb.cmd echo "detach" >> gdb.cmd echo "q" >> gdb.cmd gdb -x gdb.cmd -p `pidof mysql`
- If the error message "counter overflow" is displayed when you merge profiles in step 3, you can add the environment variable LLVM_PROFILE_FILE=$PROFILE_DATA_PATH/code-%p to generate sampling files by process, reducing sampling exceptions caused by coupling between processes.
Parent topic: PGO