carloskiki / pulldown-latex

A pull parser for LaTeX parsing and mathml rendering.
MIT License
21 stars 0 forks source link

Profile-Guided Optimization (PGO) benchmark report #6

Open zamazan4ik opened 1 month ago

zamazan4ik commented 1 month ago

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

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:

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 commented 1 month ago

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 :)