Various materials about Profile Guided Optimization (PGO) and other similar stuff like AutoFDO, Bolt, etc.
There is an (unfinished) article about all the details about PGO, PLO, etc. - link. With high chance, it will answer (almost) all your questions about PGO and PLO.
- What is PGO:
Also, you could find PDO (Profile Directed Optimization), FDO (Feedback Driven Optimization), FBO (Feedback Based Optimization), PDF (Profile Directed Feedback), PBO (Profile Based Optimization) - do not worry, that's just a PGO but with a different name.
Additionally, I need to mention Link-Time Optimization (LTO) since usually PGO is applied after LTO (since usually LTO is easier to enable and it brings significant performance and/or binary size improvements). PGO does not replace LTO but complements it. More information about LTO can be found in lto.md
.
Here I collect links to the articles/benchmarks/etc. with PGO on multiple projects (with numbers!).
- Rust (the
rustc
compiler): - Clang:
- Official documentation
- KDE blog
- Libclang on Windows: Article
- Homebrew benchmarks: one, two
- ScyllaDB benchmarks: GitHub issue
- Clang on Windows: Phoronix post
- Fedora experiments: GitHub repo
- GCC:
- ArchLinux bugtracker. Numbers for GCC 3.3 - could be outdated.
- NixOS experiments
- PGO effects on devirtualization in C++
- According to the experiments from a person in a local Telegram chat with optimization GCC in Gentoo: +4% to compilation speed with LTO, +10% to compilation speed with PGO
- Python:
- Go (
go
compiler): - D:
- DMD: GitHub issue
- LDC: GitHub comment, this and this articles
- Julia:
- PHP:
- Perl (cperl): Blog
- Ruby: Ruby Forum (post from 2006 with GCC 4.1)
- Lua: Lua interpeter results - Reddit
- tfcompile: GitHub comment
- SWI-Prolog: GitHub comment
- Sage: GitHub issue
- cel-rust: GitHub issue
- cairo-vm: GitHub comment
- scarb: GitHub comment
- Clangd:
- Clang-Tidy: GitHub issue
- lld: GitHub issue
- clang-format: GitHub comment
- Uncrustify: GitHub issue
- Android tooling like
dex2oat
: Medium - typos: GitHub issue
- Rust Analyzer: GitHub comment
- pylyzer: GitHub discussion
- ctags: GitHub comment
- gitui: GitHub comment
- fennec: GitHub comment
- Linux kernel:
- Paper
- Google results with Sampling PGO
- Microsoft presentation
- ASOS (Application Specific Operating System)
- TCP Stream perf
- Phoronix post
- Another Phoronix article
- Yet another attempt to PGO Linux kernel: http://coolypf.com/kpgo.htm
- Gentoo Wiki
- Optimizing Linux kernel with Clang. An article(in Russian) and results
- From my experience and tests, PGO with Linux kernel could be tricky to perform and does not bring huge results for 3rd party applications(tested on Redis and PostgreSQL). Further testing is needed. One possible idea - PGO was not applied right with GCC due to some .gcda find path issues. The test must be repeated with GCC and Clang.
- Windows: 5-20% improvement according to the presentation
- PostgreSQL:
- See "postgresql_results.md" file in the repo.
- Mailing list thread
- MariaDB:
- MySQL:
- ClickHouse: GitHub issue
- MongoDB: See "mongodb.md" file in the repo
- Redis: See "redis.md" file in the repo
- SQLite:
- See "sqlite.md" file in the repo for the detailed report
- SQLite forum discussion
- sqlite-parquet-vtable PGO results
- YDB: GitHub issue
- FoundationDB: GitHub issue
- DuckDB: GitHub comment
- Memcached: GitHub issue
- DragonflyDB: GitHub comment
- YugabyteDB: GitHub commit
- ScyllaDB:
- GitHub PR
- From a private conversation with Konstantin Osipov, PGO for ScyllaDB Enterprise builds achieves 5-7% performance boost, sometimes up to 10%
- GreptimeDB: GitHub issue
- Databend: GitHub issue
- Skytable: GitHub issue
- Tarantool: GitHub issue
- RonDB: GitHub comment
- ReDB:
- GitHub comment in the main repo
- GitHub comment in NativeDB repo (has PGO results for ReDB too)
- Nebula: Docs
- Qdrant:
- OceanBase: GitHub comment
- NativeDB: GitHub issue
- Dolt: Blog
- bbolt-rs: GitHub comment
- libmdbx: GitFlic issue (in Russian)
- candystore: GitHub comment
- canopydb (also
redb
,sled
,sanakirja
): GitHub comment
- Vector: GitHub issue
- Fluent-Bit: GitHub comment
- Rsyslog: GitHub comment
- Some logs parsing routines: Blog
- Envoy: GitHub comment
- HAProxy:
- Nginx: see "nginx.md" file in the repo
- Rathole: GitHub discussion
- httpd: see "httpd.md" file in the repo
- Unreal Engine:
- Release notes (search for "PGO" on the page)
- Some notes on GitHub
- Suricata: Slides
- Handbrake: GitHub issue comment
- CP2K: Docs
- Bevy: PGO-run (first) vs non-PGO (second) - Pastebin. In these results you need to interpret performance decrease as "Release version is slower than PGOed" and performance increase as "Release version is faster than PGOed".
- Wordpress: Bitnami blog
- Zstd and LZ4: Blosc blog
- Windows terminal: GitHub PR
- Drill: GitHub issue
- Goose: Article
- Chess engines (Stockfish, Cfish, asmFish): Reddit post
- Multiple smaller benchmarks by Phoronix:
- Benchmarks from OpenSUSE: Docs
- Bunch of LLVM test suite algorithms benchmarks: Blog
- ClamAV: Blog
- Mesa: Mailing list about OpenGL benchmark. Worth reading the whole thread though.
- hck: README note
- Typst: GitHub issue
- Cemu: GitHub comment
- Pydantic-core: GitHub comment
- xz: OpenMandriva forum
- libspng: Docs
- matchit: GitHub issue
- QOAudio (Rust version): GitHub issue
- JSON libraries (
serde_json
,rustc_serialize
,simd-json
): GitHub issue - XML libraries:
xml-rs
: GitHub issuequick-xml
: GitHub issueroxmltree
: GitHub issue
tonic
: GitHub issuetantivy
: GitHub issue- Lychee: GitHub issue
- nushell: GitHub comment
- delta: GitHub comment
- hurl: GitHub comment
- fd: GitHub comment
- MRCC: up to 40% performance boost with PGO according to the private benchmarks
- Broot: GitHub issue
- Geant4 (a CERN project):
- Youki: GitHub issue
- sd: GitHub issue
- frawk: GitHub comment
- bat: GitHub issue
- jql: GitHub issue
- htmlq: GitHub issue
- ouch: GitHub issue
- czkawka: GitHub issue
- quilkin: GitHub comment
- grcov: GitHub issue
- difftastic: GitHub issue
- Perspective: GitHub discussion
- tquic: GitHub issue
- legba: GitHub issue
- Slint: GitHub issue
- tsv-utils: Study report
- wgpu: GitHub discussion
- Mesa: Phoronix post
- lingua-rs: GitHub discussion
- libtre: FreeBSD Bugzilla comment
- ion:
- Instrumented to Release: https://gist.github.com/zamazan4ik/200b179278bcad05528eb65340977781
- PGO-optimized to Release: https://gist.github.com/zamazan4ik/a4c5b603c16ec9fe3427c9d26a50e3e5
- Platform: Linux
- ion version:
master
branch on60bfb73351f0412c95b8ba2afe75e988514470a6
commit
- tokei: GitHub issue
- qsv: GitHub discussion
- vtracer: GitHub discussion
- ripgrep: GitHub comment
- lol-html: GitHub issue
- tokenizers: GitHub issue
- Zen: GitHub discussion
- native_model: GitHub issue
- pathfinding: GitHub issue
- HiGHS: near 2-2.5% in
highs ../check/instances/greenbea.mps
workload - lace: GitHub issue
- minitrace-rust: GitHub issue
- needletail: GitHub issue
- logos: GitHub issue
- llrt: GitHub issue
- varpro: GitHub issue
- awk: LWN article
- gawk: GitHub commit
- candy: GitHub discussion
- axum: GitHub dicussion
- rustls: GitHub issue
- python-libipld: GitHub PR
- sqlparser-rs: GitHub discussion
- arrow-datafusion: GitHub discussion
- actson-rs: GitHub issue
- oha: GitHub PR
- rust_serialization_benchmark: GitHub issue
- ada-url: GitHub issue
- struson: GitHub discussion
- ast-grep: GitHub discussion
- Symbolicator: GitHub issue
- libjxl: GitHub issue
- nucleo: GitHub discussion
- martin: GitHub discussion
- serde-sqlite-jsonb: GitHub discussion
- LibreOffice: Blog. The article is from 2014 - keep it in mind.
- A lot of insights, history, and great benchmarks for LTO and PGO efficiency in LLVM and GCC in various software (including Firefox and LibreOffice) from Honza Hubička: GCC 4.8, GCC 5, GCC 6 and Clang 3.9, GCC8 and Clang 6, GCC9
- koto: GitHub discussion
- prost: GitHub discussion
- angle-grinder: GitHub discussion
- zune-image: GitHub discussion
- graphql-lint: GitHub issue
- nom: GitHub comment
- prettyplease: GitHub comment
- genson-rs: GitHub comment
- resvg: GitHub comment
- Cloudflare (internal services): Blog
- rustwire: GitHub comment
- Bend: GitHub comment
- Amber: GitHub discussion
- Iggy-rs: GitHub comment
- html5ever: GitHub comment
- Symbolica: Zulip message
- oxc: GitHub comment
- libvpx: Chromium issue tracker
- lady-deirdre: GitHub comment
- musli: GitHub discussion
- limbo: GitHub comment
- amber: GitHub comment
- OpenRadioss: GitHub comment
- ieee80211-rs: GitHub comment
- jiff, chrono, time: GitHub discussion
- pulldown-latex: GitHub comment
- vrl: GitHub discussion
- Picodrive: Habr comment (in Russian. 2x performance improvement)
- harper: GitHub discussion
- wildcard: GitHub comment
- GQL: GitHub discussion
- trie-hard, radix-trie: GitHub comment
- pingora: GitHub discussion
- tex-fmt: GitHub comment
- grex: GitHub discussion
- rust-lexical: GitHub comment
- serde-brief: GitHub comment
- dune: GitHub comment
- Multiple Jinja engines (
rinja
,minijinja
,tera
,liquid
,handlebars
,askama
): GitHub comment - arrow-rs: GitHub discussion
- ion (from RedoxOS): Benchmark results
- cosmic-text: GitHub discussion
- gimli: GitHub discussion
- osmgraph: GitHub comment
Below you can find some examples of where and how PGO is integrated into different projects.
- Rustc: a CI tool for the multi-stage build
- GCC:
- Clang:
- Python:
- Go: Bash script
- Swift: CMake script
- Julia: Makefiles
- V8: Bazel flag
- ChakraCore: Scripts
- Chromium: Script
- Firefox: Docs
- Thunderbird has PGO support too
- PHP - Makefile command and old Centminmod scripts
- MySQL: CMake script
- YugabyteDB: GitHub commit
- FoundationDB: Script
- Zstd: Makefile
- Foot: Scripts
- Windows Terminal: GitHub PR
- Pydantic-core: GitHub PR
- file.d: GitHub PR
- OceanBase: CMake flag
- ISPC: CMake scipts
- NodeJS: Configure script
- Android Open Source Project (AOSP):
- Official documentation
- Committed PGO profiles: repository
- DMD: Custom build rule
- LDC: GitHub action
- tsv-utils: Makefile
- Erlang OTP: Makefile
- Clingo (PGO enabled only in Spack): Package recipe
- SWI-Prolog:
- hck: Justfile
- oha: GitHub PR
- Dolt: Blog
- SVT-AV1: CMake script
- ScyllaDB: from a private conversation with Konstantin Osipov - PGO is enabled for ScyllaDB Enterprise builds
Here we collect projects where PGO is described as an optimization option in the documentation:
- ClickHouse: https://clickhouse.com/docs/en/operations/optimizing-performance/profile-guided-optimization
- Databend: https://databend.rs/doc/contributing/pgo
- Vector: https://vector.dev/docs/administration/tuning/pgo/
- Nebula: https://docs.nebula-graph.io/3.5.0/8.service-tuning/enable_autofdo_for_nebulagraph/
- GCC: Official docs, section "Building with profile feedback" (even AutoFDO build is supported)
- Clang:
- Rustc: https://rustc-dev-guide.rust-lang.org/building/optimized-build.html#profile-guided-optimization
- tsv-utils: https://github.com/eBay/tsv-utils/blob/master/docs/BuildingWithLTO.md
- SVT-AV1: https://gitlab.com/AOMediaCodec/SVT-AV1/-/blob/master/Docs/CommonQuestions.md#why-build-with-pgo
- ieee80211-rs: https://github.com/Frostie314159/ieee80211-rs?tab=readme-ov-file#optimization
- serde-brief: https://github.com/FlixCoder/serde-brief/blob/main/docs/pgo.md
- C and C++:
- Rust:
- Fortran:
- C#:
- Java:
- GraalVM (already free to use)
- Go:
- Go compiler in Preview since Go 1.20, GA in 1.21
- GoLLVM - not yet
- GCCGO - unknown, but it should be possible to try
- Swift: Seems like supports but I am not sure
- Kotlin: Seems like no
- Ada:
- GNAT: should be possible, same as GCC
- D: LDC docs
- Nim: Nim forum
- Ocaml: almost no
- Zig: no
- V: kind of
- Red: seems like not
- Pascal: No
- Haskell:
- GHC: no
Possibly other compilers support PGO too. If you know any, please let me know.
Here we collect and track PGO integrations into build systems:
- Cargo: No built-in support but there is awesome cargo-pgo
- Bazel: Supports (command-line reference)
- CMake: No support yet (GitLab issue)
- Meson: Supports (
b_pgo
in the docs). - SCons: No support yet (GitHub discussion)
- YPKG (Solus): The addition of the
profile
key the in thepackage.yml
format will perform an automatic PGO build docs. (Example) - boulder (Serpent OS): The addition of the
workload
key in thestone.yaml
format will perform an automatic PGO build TODO: no docs available?
Check "are_we_pgo_yet.md" file in the repo to check the PGO status in a project.
Here I collect all results by applying LLVM BOLT to the projects (with numbers).
- Linux kernel:
- Rustc:
- CPython: GitHub PR
- YDB: GitHub comment
- Clang:
- LDC: GitHub comment
- HHVM, Proxygen and others: Facebook paper
- NodeJS: Blog
- Chromium: Blog
- MySQL, MongoDB, memcached, Verilator: Paper
- PostgreSQL: Blog
- ast-grep: GitHub issue
- Symbolicator: GitHub issue
- Pango: Gnome blog
- pylyzer: GitHub discussion
- prettyplease: GitHub comment
- bbolt-rs: GitHub comment
- resvg: GitHub comment
- julia: GitHub PR
- Rustc: GitHub PR
- CPython: GitHub PR
- Pyston:
- Clang: CMake script
- Linux kernel:
Just a list of BOLT-related issues in different projects. So you can estimate the BOLT state in your favorite open-source product.
- Chromium: Chromium bugtracker
- Firefox: Mozilla bugtracker
- The same for Propeller: Mozilla bugtracker
- NodeJS: GitHub issue
- LDC: GitHub issue
- GCC: Bugzilla
Even if PGO is supported by a project, it does not mean that your favorite Linux distro builds this project with PGO enabled. For this there are a lot of reasons: maintainer burden (because we are humans (yet)), build machines burden (in general you need to compile twice), reproducibility issues (like profile is an additional input to the build process and you need to make it reproducible), a maintainer just don't know about PGO, etc.
So here I will try to collect information about the PGO status across the Linux distros for the projects that support PGO in the upstream. If you didn't find your distro - don't worry! Just check it somehow (probably in some chats/distros' build systems, etc.) and report it here (e.g. via Issues) - I will add it to the list.
- GCC:
- Note: PGO for GCC usually is not enabled for all architectures since it requires too much from the build systems
- Debian: yes
- Ubuntu: same as Debian
- RedHat: Yes. And that is the reason why PGO is enabled for GCC in all RedHat-based distros.
- Fedora: yes
- Rocky Linux: yes
- Alma Linux: yes
- NixOS: no
- OpenSUSE: yes, see line
2414
- Solus: yes
- Clang:
- Rustc:
- CPython:
- LDC:
- Solus: yes
Here we track LLVM BOLT enablement across various projects in various OS-specific build scripts:
- Clang:
- Gentoo bugtracker
- Solus: disabled Due to: llvm/llvm-project#111530
- GCC: TODO
- Rustc:
- Fedora: no
- RedHat: no
- CPython: TODO
- Pyston: TODO
- LDC:
- Solus: yes
Meta-issues about PGO and LLVM BOLT usage in different OSs and package managers:
- Fedora:
- RedHat: JIRA about llvm-bolt addition
- ClearLinux: GitHub issue
- CachyOS (Website): according to the search over its GitHub repositories - they are trying to integrate BOLT as much as possible
- OpenSUSE: Cannot create an account to create a corresponding issue
- Ubuntu: Ubuntu forums
- Alpine Linux: Gitlab issue
- Mageia: Bugzilla
- Void Linux: GitHub issue
- Chromebrew: GitHub discussion
- Homebrew: GitHub discussion
- Spack: GitHub discussion
- Vcpkg: GitHub discussion
- FreeBSD: FreeBSD forum
- Conan: GitHub issue
- MacPorts: Ticket
- They said this question should be discussed in mailing lists
- LLVM-mingw: GitHub issue
- MinGW repo: GitHub issue
- CBL-Mariner: GitHub discussion
- Implementation details of different PGO approaches in Clang: Youtube, slides
- Some notes about PGO
- A rejected idea to integrate BOLT into
cpython
build: link - cperl notes on LTO, PGO, BOLT
.profraw
internal details: blog- Slides about PGO from C++ Russia 2021 (Pavel Kosov): slides (in Russian), video
- Overview of all kinds of PGO in LLVM: link
- MSVC insights about PGO (a video from 2012): Microsoft learn
I spent some time on giving talks about PGO at different conferences. Multiple times people were asking me to share slides/videos. Here they are.
Few notes about them:
-
None of this talks contains all the material from this repository since it's impossible to cover all PGO nuances during a talk at a conference. That's why reading the article is highly recommended anyway.
-
You can see that multiple talks have the same or almost the same content. That's fine since different conferences usually have different people that didn't listen talks from other conferences. For you it means that you don't need to watch / listen all the presentations. But if you want - you are welcome!
-
TechSpot 2024 "Performance meetup" (Warsaw, Poland), “Profile-Guided Optimization (PGO): 101” (video, slides)
-
Winglang Community Meeting March 2024 (Online), “Profile-Guided Optimization (PGO) for Winglang” (slides)
-
Tech Internals Conf 2024 (Cyprus), “Profile-Guided Optimization (PGO): (Ab)using it for fun and profit” (video, slides)
-
OxidizeConf 2024 (Berlin, Germany), “Profile-Guided Optimization (PGO) in Rust - 101” (video, slides)
-
RustFest 2024 (Zurich, Switzerland), “Profile-Guided Optimization (PGO) in Rust: unknown parts” (slides)
-
p99conf 2024 (Online), “Profile-Guided Optimization (PGO): (Ab)using it for Fun and Profit” (video, slides)
-
RustLab 2024 (Florence, Italy), “Profile-Guided Optimization (PGO) for Rust applications: Practical Guide” (video, slides)
- Awesome Machine learning in compilers
- CompilerGym: https://github.com/facebookresearch/CompilerGym/ (an interesting project about applying ML on compiler optimization flags)
- MLGO: A Machine Learning Framework for Compiler Optimization: Google blog
- Phoronix Test Suite (PTS) integration with PGO: GitHub
- An article about BOLT
- Nvidia paper about PGO in gamedev: Publication
If you have an example where PGO shines (and where doesn't) - please open an issue and/or PR to the repo. It's important to collect as many as possible showcases about PGO!