Implement Profile-Guided Optimization (PGO) for Crystal lang

Hi!

I want to discuss the idea of implementing Profile-Guided Optimization (PGO) for the Crystal lang. PGO is an optimization technique to perform compiler optimizations based on some collected in runtime statistics like which code paths are executed more frequently, etc. - it allows the compiler to perform better optimization decisions like inlining, hot/cold code splits, etc.

I collect various materials about PGO (benchmarks, articles, etc.) in my GitHub repo.

According to my tests, PGO helps a lot with improving software performance in many domains (compilers, databases, log solutions, etc.) I want to discuss an idea about implementing PGO support for the Crystal compiler. It will allow to optimize Crystal-based applications even more, including the Crystal compiler performance itself.

All major native compilers for langs like C, C++, Rust, D, Fortran already support PGO, including many LLVM-based compilers since LLVM implements many PGO primitives.

What do you think about the idea? Did you have such discussions before?

Thank you.

4 Likes

Related: Rust uses PGO to optimize rustc, including libllvm.
Here’s an interesting article about the process and some efforts for improving it:

via lobste.rs

1 Like