Profile-guided optimization
For example, inferring or placing formal constraints on the number of iterations a loop is likely to execute is fundamentally useful when considering whether to unroll it or not, but such facts typically rely on complex runtime factors that are difficult to conclusively establish.[5][6][7] The compiler accesses profile data from a sample run of the program across a representative input set.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.The HotSpot Java virtual machine (JVM) uses profile-guided optimization to dynamically generate native code.[11] Google published a paper [12] describing a tool in use for using production profiles to guide builds resulting in up to a 10% performance improvement.