Jump to content

Profile-guided optimization

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Materialscientist (talk | contribs) at 06:45, 13 November 2016 (Reverted 1 edit by Adelino Pedro armando identified as test/vandalism using STiki). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Profile-guided optimization (PGO, sometimes pronounced as pogo[1]), also known as profile-directed feedback (PDF)[2] and feedback-directed optimization (FDO),[3] is a compiler optimization technique in computer programming that uses profiling to improve program runtime performance.

Method

Optimization techniques based on analysis of the source code alone are based on general ideas as to possible improvements, often applied without much worry over whether or not the code section was going to be executed frequently though also recognising that code within looping statements is worth extra attention.

The first high-level compiler, introduced as the Fortran Automatic Coding System in 1957, broke the code into blocks and devised a table of the frequency each block is executed via a simulated execution of the code in a Monte Carlo fashion in which the outcome of conditional transfers (as via IF-type statements) is determined by a random number generator suitably weighted by whatever FREQUENCY statements were provided by the programmer.[4]

Rather than programmer-supplied frequency information, profile-guided optimisation uses the results of profiling test runs of the instrumented program to optimize the final generated code.[5][6] The compiler is used to access data from a sample run of the program across a representative input set. The results indicate which areas of the program are executed more frequently, and which areas are executed less frequently. All optimizations benefit from profile-guided feedback because they are less reliant on heuristics when making compilation decisions. The caveat, however, is that the sample of data fed to the program during the profiling stage must be statistically representative of the typical usage scenarios; otherwise, profile-guided feedback has the potential to harm the overall performance of the final build instead of improving it.

Just-in-time compilation can make use of runtime information to dynamically recompile parts of the executed code to generate a more efficient native code. If the dynamic profile changes during execution, it can deoptimize the previous native code, and generate a new code optimized with the information from the new profile.

Adoption

There is support for building Firefox using PGO.[7] Even though PGO is effective, it has not been widely adopted by software projects, due to its tedious dual-compilation model.[8] It is also possible to perform PGO without instrumentation by collecting a profile using hardware performance counters.[8] This sampling-based approach has a much lower overhead and does not require a special compilation.

The HotSpot Java virtual machine (JVM) uses profile-guided optimization to dynamically generate native code. As a consequence, a software binary is optimized for the actual load it is receiving. If the load changes, adaptive optimization can dynamically recompile the running software to optimize it for the new load. This means that all software executed on the Hotpot JVM effectively make use of profile-guided optimization.[9]

PGO has been adopted in the Windows version of Google Chrome. PGO was enabled in the 64-bit edition of Chrome starting with version 53 and version 54 for the 32-bit edition.[10]

Implementations

Examples of compilers that implement PGO are:

See also

References

  1. ^ a b "Microsoft Visual C++ Team Blog".
  2. ^ "Profile-directed feedback (PDF)". Retrieved 23 November 2013.
  3. ^ "Hardware Counted Profile-Guided Optimization". 24 November 2014. arXiv:1411.6361. {{cite journal}}: Cite journal requires |journal= (help); Unknown parameter |authors= ignored (help)
  4. ^ J. W. Backus, R. J. Beeber, et al., The Fortran Automatic Coding System, Proceedings of the Western Joint Computer Conference, February 1957, p. 195
  5. ^ a b "Intel Fortran Compiler 10.1, Professional and Standard Editions, for Mac OS X". Archived from the original on 28 September 2013.
  6. ^ "Profile-Guided Optimization (PGO) Quick Reference".
  7. ^ Building with Profile-Guided Optimization, mozilla.org, 13 August 2013
  8. ^ a b Dehao Chen (2010), "Taming hardware event samples for fdo compilation", Proceedings of the 8th annual IEEE/ACM international symposium on Code generation and optimization, pp. 42–52.
  9. ^ Ivanov, Vladimir (25 July 2013). "JVM JIT compilation overview". Retrieved 10 September 2016.
  10. ^ Marchand, Sébastien (31 October 2016). "Making Chrome on Windows faster with PGO". Archived from the original on 1 November 2016. Retrieved 1 November 2016. {{cite web}}: Unknown parameter |dead-url= ignored (|url-status= suggested) (help)