First, feedback compilation
Introduction to the
PGO, i.e. profile-guided Optimizations, feedback optimization. PGO is another compiler optimization technique. One obvious difference between PGO and some other optimization techniques/options is that PGO optimization is a dynamic optimization process with three steps.
Feedback optimization process:
- Procedure Step 1 The compiler generates an executable file for staking.
- Step 2 Run the executable file of the peg to generate the feedback data file GCDA, which records the execution times on the control flow diagram in the program.
- Step 3 The compiler reads the feedback data file and uses the feedback optimization to generate high-performance executable files.
The following optimizations benefit from feedback data:
Register allocation, basic block rearrangement, inlining, loop unrolling, instruction scheduling, redundant instruction deletion, etc.
Note: Feedback data needs to be regenerated when code changes.
Basic options
Compile to get the peg version binary or so
GCC main.c -- fprofile-generate -- o instrument.outCopy the code
Gcda feedback compilation data is obtained by running on board
./instrument.out
Copy the code
Recompile from the feedback data
GCC main.c -- fprofile-use -- o new.outCopy the code
Second, the FGO
PGO is the original feedback compilation optimization scheme of GCC. It guides the second compilation optimization by running the gCDA files sampled by plugging. FGO, aiming at the binary properties of GCDA files, solves the pain points of source code delivery on the business side. The difference is that FGO profiles can be adapted with appropriate manual modifications, but currently FGO does not fully support C++ module optimization.
Third, softFDO
SoftFDO converts the sampling data obtained through native piling operation into Google open source GCOV data format, and imports the data through Auto-profile Pass for optimization. The difference between the two is that PGO supports value profiles while softFDO does not. The Auto-profile Pass edge used by softFDO calls the early-inline operation when optimized