Application Feedback Optimization
- Compile and install MySQL for the first time.If the source code is located in /home/mysql-8.0.24, run the following commands in this directory:
1 2 3 4 5 6 7
# Create a profile storage directory. mkdir gcc_build cd gcc_build cmake .. -DCMAKE_INSTALL_PREFIX=/home/mysql-8.0.24/gcc_build/ -DBUILD_CONFIG=mysql_release -DWITH_BOOST=../boost -DCMAKE_CXX_FLAGS="-fcfgo-profile-generate=/home/mysql-8.0.24/gcc_build/mysql_profile/pgo_profile" -DCMAKE_C_FLAGS="-fcfgo-profile-generate=/home/mysql-8.0.24/gcc_build/mysql_profile/pgo_profile" make -j && make install -j
- Start MySQL.
1/home/mysql-8.0.24/gcc_build/bin/mysqld --defaults-file=/etc/my.cnf &
- Run the benchmark test. Sysbench is used as an example.
1sysbench ./oltp_write_only.lua --threads=256 --mysql-user=root --mysql-password=123456 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-db=sysbench --forced-shutdown=off --time=120 --report-interval=1 --events=0 --table-size=10000000 --tables=1 run
- After the benchmark test is completed, the profile will be generated in /home/mysql-8.0.24/gcc_build/mysql_profile/pgo_profile.
After optimization:
1 2 3
cmake .. -DCMAKE_INSTALL_PREFIX=/home/mysql-8.0.24/gcc_build_pgoed -DBUILD_CONFIG=mysql_release -DWITH_BOOST=../boost -DCMAKE_CXX_FLAGS="-fcfgo-profile-use=/home/mysql-8.0.24/gcc_build/mysql_profile/pgo_profile -fprofile-correction -Wno-error=coverage-mismatch -Wno-error=missing-profile" -DCMAKE_C_FLAGS="-fcfgo-profile-use=/home/mysql-8.0.24/gcc_build/mysql_profile/pgo_profile -fprofile-correction -Wno-error=coverage-mismatch -Wno-error=missing-profile" make -j && make install -j
If you encounter "error: 'SYS_gettid' was not declared in this scope" during installation, you can resolve it by adding #include "sys/syscall.h" at the beginning of /home/mysql-8.0.24/storage/innobase/buf/buf0buff.cc.
Parent topic: PGO