Tuning by the GCC PGO
Purpose
Profile-guided optimization (PGO), also known as feedback-directed optimization, is a compiler optimization technology. PGO is a dynamic optimization process where a pre-test is required. The pre-test samples a program, obtains features such as hotspot functions and function distribution of the program, and feeds sample data to the next compilation. Based on the sample data, the compiler re-compiles the program to generate an optimized one.
Procedure
- Compile Redis.
make CFLAGS="-fprofile-generate=/opt/gcc_profile" LDFLAGS="-fprofile-generate=/opt/gcc_profile" -j
- Start Redis. For details, see the Starting Redis section in the Redis Deployment Guide.
- Test Redis on the Redis client and obtain the sampling result.
- Stop Redis.
redis-cli -h 192.168.222.124 -p 6379 shutdown
192.168.222.124 and 6379 are the IP address and port number of the Redis server. Change them according to the actual configurations.
- Clean up build results for recompilation.
make distclean
Before recompiling with the collected data, clean up the previous build results to avoid interference.
- Recompile Redis.
make CFLAGS="-fprofile-use=/opt/gcc_profile -fprofile-correction -Wno-error=coverage-mismatch" LDFLAGS="-fprofile-use=/opt/gcc_profile -fprofile-correction -Wno-error=coverage-mismatch" -j
/opt/gcc_profile is the directory for storing sampling files, which can be customized. If GCC PGO needs to be performed again, delete the data from the /opt/gcc_profile directory to avoid confusion.