Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profile-Guided Optimization (PGO) benchmark report #6

Open
zamazan4ik opened this issue Aug 5, 2024 · 1 comment
Open

Profile-Guided Optimization (PGO) benchmark report #6

zamazan4ik opened this issue Aug 5, 2024 · 1 comment

Comments

@zamazan4ik
Copy link

Hi!

I was interested in optimizing the library's performance even further. I evaluated Profile-Guided Optimization (PGO) on many projects - all the results are available at https://github.com/zamazan4ik/awesome-pgo . Since this compiler optimization works well in many places, especially different parsers, I decided to apply it to the project - here are my benchmark results.

Test environment

  • Fedora 40
  • Linux kernel 6.9.12
  • AMD Ryzen 9 5900x
  • 48 Gib RAM
  • SSD Samsung 980 Pro 2 Tib
  • Compiler - Rustc 1.79
  • pulldown-latex version: main branch on commit 62cbc23a48ab3828dfd70e177227e7d3c03bb042
  • Disabled Turbo boost

Benchmark

For benchmark purposes, I use built-in into the project benchmarks. For PGO optimization I use the cargo-pgo tool. Release bench result I got with taskset -c 0 cargo bench command. The PGO training phase is done with taskset -c 0 cargo pgo bench, PGO optimization phase - with taskset -c 0 cargo pgo optimize bench.

taskset -c 0 is used for reducing the OS scheduler's influence on the results. All measurements are done on the same machine, with the same background "noise" (as much as I can guarantee).

Results

I got the following results:

According to the results, PGO measurably improves the library's performance in many cases.

Further steps

I can suggest the following action points:

  • Perform more PGO benchmarks with other datasets (if you are interested enough). If it shows improvements - add a note to the documentation (the README file, I guess?) about possible improvements in the library's performance with PGO.
  • Probably, you can try to get some insights about how the code can be optimized further based on the changes that the compiler performed with PGO. It can be done via analyzing flamegraphs before and after applying PGO to understand the difference or checking some assembly/LLVM IR differences before and after PGO. However, this job can be boring and time-consuming - and the compiler already does all the job automatically when PGO is used.

I would be happy to answer your questions about PGO.

P.S. I created the issue just because Discussions are disabled for the repository. It's just a benchmark report, not a bug or smth like that.

@carloskiki
Copy link
Owner

Wow thank you so much! I had never heard of PGO before, apart from the usual "always optimize based on profiling." I did not know there were tools that analyze the binary and optimize it "automatically," this is super nice! I will keep this open for now, I think its a great thing but as of now the crate is still to much in development to start optimizing it.

As an aside, I have opened the discussion tab for the repo :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants