Right now I am testing Profile-Guided Optimization (PGO) and LLVM BOLT effects in multiple software domains - all current results are available here. During the research, I have met multiple questions about PGO status in Swift that I want to discuss here.
- Does Switft support building Swift programs with PGO? I am trying to find something similar to the Clang docs about PGO but for Swift - didn't find any on the Internet. If you have such a link - could you please share it with me? The only link that I found is the source code with some PGO-related flag in the compiler: GitHub. Would be nice to have a dedicated manual for PGO (as it's done in other compilers like Clang, GCC, Rustc).
- If Swift supports PGO, what kind of PGO is it? Instrumentation, Sampling, or something else? Is it possible to use the AutoFDO project with Swift?
- As far as I see in the closed PRs, Swift compiler already supports building with PGO for both parts (Swift compiler itself and LLVM part). Does it support optimizing the compiler with LLVM BOLT? E.g. Clang and Rustc compilers already support optimizing with LLVM BOLT.
- Do you optimize prebuilt Swift compiler binaries with PGO? If yes, could you please share somewhere performance results after enabling PGO? It helps a lot to the maintainers of the custom Swift compiler builds with estimation - do they need to build Swift compiler with PGO/BOLT or not.
- How do you collect the PGO profile for the Swift compiler? Is there any committed profile or it's regenerated on each build? If there are some ready-to-use scripts for it - would be awesome if you could show them.
- Do you use PGO for optimizing other Swift-related tooling (like the code-formatters)? It could be an interesting topic since according to my tests on LLVM tooling - helps a lot for different kinds of LLVM-based software (code formatting, language server, static analysis).
Thanks in advance!