Because you can all download binaries for LDC 1.1.0-alpha1 now,
it is time to release the article on how to use profile-guided
optimization with the new LDC release.
Please test and report back to us! :)
Three months ago, I measured a 7% performance gain of the
compiler front-end D code using Profile-Guided Optimization (PGO)
with LDC. Now, part of my PGO work was merged into LDC master on
Jun 20, 2016! This means it will be available in the next LDC
release (version 1.1.0, needs LLVM 3.7 or newer). You can play
with it with the LDC 1.1.0-alpha1 release. Here I’ll discuss how
to use it, saving the implementation details for another article.
Using PGO with LDC is similar to using PGO with Clang, and much
of this article also applies to Clang.
Profile-Guided Optimization (PGO)
“Profile-guided optimizations” are optimizations that the
compiler can do when it is given information about the typical
execution flow of your program, such that the typical execution
flow of your program runs faster (and rare execution flows run
slower). The typical execution flow information is the “profile”
of your program: how many times was this function called, how
often was a control-flow branch taken, how often was function A
called by function B, what are likely values of variable X, how
much memory is usually allocated for something, etc.