Usage
- Instrumentation
1 2 3 4 5 6 7
# At compile time, add the link option (--emit-relocs or -q) for enabling relocation. # Instrumentation llvm-bolt ./install.bolt/bin/mysqld -instrument -o mysqld.inst -instrumentation-file=mysqld.fdata --instrumentation-wait-forks -instrumentation-sleep-time=2 -instrumentation-no-counters-clear --instrumentation-binpath=mysqld.inst # Replace the original binary with the instrumented binary mysqld.inst, and then run it to collect running information. # FDO binary llvm-bolt ./install/bin/mysqld -o mysqld.opt -data=mysqld.fdata --infer-fall-throughs --reorder-blocks=ext-tsp --reorder-functions=hfsort --peepholes=useless-branches --simplify-conditional-tail-calls --simplify-rodata-loads --indirect-call-promotion-use-mispredicts --elim-link-veneers --eliminate-unreachable --fix-block-counts --fix-func-counts --split-all-cold --sctc-mode=preserve --align-blocks --cg-use-split-hot-size --tail-duplication=aggressive --iterative-guess --assume-abi # Run the optimized version.
- perf sampling
For example, to optimize MySQL, run the following commands on the x86 server:
1 2 3 4 5 6 7 8
# At compile time, add the link option (--emit-relocs or -q) for enabling relocation. # Start the service process. # Sampling perf record -e cycles:u -j any,u -o /tmp/profile.data -p `pidof mysqld` -- sleep 600 # /usr/local/mysql-8.0.25/bin/mysqladmin -uroot -p123456 -S /data/mysql/run/mysql.sock shutdown perf2bolt -p=mysqld.data ./install/bin/mysqld -o mysqld.fdata # FDO binary llvm-bolt ./install.bolt/bin/mysqld -o mysqld.opt -data=mysqld.fdata --infer-fall-throughs --reorder-blocks=ext-tsp --reorder-functions=hfsort --indirect-call-promotion=all --indirect-call-promotion-use-mispredicts --peepholes=useless-branches --simplify-conditional-tail-calls --simplify-rodata-loads --elim-link-veneers --eliminate-unreachable --fix-block-counts --fix-func-counts --split-all-cold --sctc-mode=preserve --align-blocks --cg-use-split-hot-size
Note that the AArch64 does not support branch events. Therefore, the sampling and conversion commands need to be changed as follows:
1 2 3 4 5 6
# Sampling. Note that there is no LBR event on the Arm. perf record -e cycles:u -o /tmp/profile.data -p `pidof mysqld` -- sleep 600 # Convert the file to a readable format by adding the -nl parameter. perf2bolt -p=mysqld.data ./install/bin/mysqld -o mysqld.fdata -nl # FDO binary. The commands are the same as the preceding commands. # Run the optimized version.
Parent topic: BOLT