Skip to content

Evaluate Profile-Guided Optimization (PGO) and LLVM BOLT #1247

@zamazan4ik

Description

@zamazan4ik

Hi!

Recently I did a lot of PGO benchmarks on different software - all available results are here. According to my tests, PGO can help with achieving better performance in many workloads. Since Lychee cares about performance (I think so because the project has benchmarks), I think it would be a good idea to test PGO on it.

So I tested PGO on Lychee on my Macbook M1 Pro, macOS 13.4, Rust 1.72 and here are the results. All tests was done via cargo bench. PGO optimization is done with cargo-pgo.

Release:

extract from large docs time:   [12.814 ms 12.908 ms 13.045 ms]
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) high severe

Release + PGO optimization (compared to Release), cargo pgo optimize bench command:

extract from large docs time:   [10.084 ms 10.098 ms 10.113 ms]
                        change: [-20.758% -20.030% -19.527%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) high severe

Release + PGO instrumented, compared to Release (I publish these numbers so you can estimate how Lychee is slow in the PGO instrumentation mode), cargo pgo bench command:

extract from large docs time:   [39.635 ms 39.781 ms 39.874 ms]
                        change: [+205.32% +207.99% +210.21%] (p = 0.00 < 0.05)
                        Performance has regressed.

As you see, at least in the provided by the projects benchmarks, PGO allows to achieve better performance.

I can suggest to do the following things:

  • Add a note to the Lychee documentation about building with PGO. In this case, users and maintainers who build their own Lychee packages will be aware of PGO as an additional way to optimize Lychee
  • Optimize provided by Lychee team binaries on the CI (like it's already done for other projects like Rustc), if you have any
  • After that, I suggest trying to apply LLVM BOLT as an additional post-PGO step. Rustc already does it on some platforms.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions