Compilers
Which describes profile-guided optimization (PGO)?
- AA feature that reformats source code to make it more readable
- BA feature where the compiler picks optimizations at random and compares the results
- CRecompiling with data recorded from runs on representative input
Show answer and explanation
Answer: C. Recompiling with data recorded from runs on representative input
In PGO, a program compiled with instrumentation is first run on representative input, recording which branches are usually taken and which functions are called often. It is then recompiled using this information, laying out hot paths straight-line and inlining frequently called functions to match actual usage. The benefit fades if the training input differs greatly from real usage. It is neither source reformatting nor random selection.
- A. Reformatting source is the job of other tools.
- B. It uses execution records, not random choices.
- C. Correct. It recompiles using recorded execution data.