facebook / facebook/pyrefly

Evaluate using Profile-Guided Optimization (PGO) and Post-Link Optimization (PLO)

Open
#349 3 comments 0 reactions 1 assignee Claimed by @asukaminato0721 View on GitHub
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

Hi!

Another optimization idea, in addition to the already completed https://github.com/facebook/pyrefly/issues/214

Recently I checked Profile-Guided Optimization (PGO) improvements on multiple projects (including many LSP servers like Clangd and Rust Analyzer) - the results are available in the [awesome-pgo](https://github.com/zamazan4ik/awesome-pgo/) repo. Since PGO has helped in many similar to `pyrefly` cases, I think it would be a good idea to try optimizing `pyrefly` by applying PGO to it.

I can suggest the following things to do:

* We need to perform PGO benchmarks on `pyrefly`. If it shows improvements - add a note about possible improvements to the documentation. Providing an easier way (e.g. a build option) to build scripts to build `pyrefly` with PGO can be useful for the end-users too.
* It will be a good idea to integrate building with PGO into your CI pipelines. In this case, users will get already PGO-optimized binaries from the website

[Here](https://github.com/zamazan4ik/awesome-pgo/) you can find different materials about PGO: benchmarks for multiple apps, examples of how PGO is already integrated with various projects, PGO support in multiple Rust compilers, and some PGO-related pieces of advice. For Rust-based applications, I recommend starting with [cargo-pgo](https://github.com/Kobzol/cargo-pgo).

After PGO, I suggest evaluating the Post-Link Optimization (with tools like LLVM BOLT) - it can give more aggressive optimizations even after PGO. However, starting with regular PGO will be easier to do. Since LLVM BOLT is mainly developed by Facebook/Meta - probably you are a bit more motivated to give it a try ;)

Thank you.

### Sandbox Link

N/A

### (Only applicable for extension issues) IDE Information

N/A

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.