lycheeverse / lychee

⚑ Fast, async, stream-based link checker written in Rust. Finds broken URLs and mail addresses inside Markdown, HTML, reStructuredText, websites and more!
https://lychee.cli.rs
Apache License 2.0
1.88k stars 116 forks source link

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

Closed zamazan4ik closed 2 months ago

zamazan4ik commented 10 months ago

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:

mre commented 8 months ago

Apologies for the delay. The numbers look promising. At the end you mentioned Ruff, but I assume you meant lychee. If you have the time, I'd be happy about the CI optimizations you mentioned.

zamazan4ik commented 8 months ago

Apologies for the delay.

No worries :)

At the end you mentioned Ruff, but I assume you meant lychee.

Whoops! Sorry - fixed that now.

If you have the time, I'd be happy about the CI optimizations you mentioned.

I will try my best but right now have quite a tight backlog with other projects. Hopefully, once will find enough time for Lychee.

mre commented 6 months ago

@zamazan4ik, is still something you'd like to tackle in the foreseeable future?

zamazan4ik commented 6 months ago

is still something you'd like to tackle in the foreseeable future?

Yep! I just want to finish my article about PGO. After that as a next step, I think I will get enough free time for integrating PGO into the build pipelines for more open-source projects (like Lychee).

mre commented 6 months ago

Awesomeness! Thanks for the update. 😊

mre commented 6 months ago

Uhm, that's not article, that's a book! πŸ˜† You should actually consider to make this an ebook or so.

zamazan4ik commented 6 months ago

Uhm, that's not article, that's a book! πŸ˜† You should actually consider to make this an ebook or so.

Huh! From my estimations, it's a half-finished article (or just a bit more like 60%). I am considering in the future creating something like a "PGO book" (as we already have an awesome Rust book, and many other similar ebooks). If the community will give feedback about creating a book - why not? Right now, you are the first person with such a request ;)

mre commented 6 months ago

Not an expert, but it looks like one of the most complete resources on the topic, especially with regards to Rust. An awesome book sounds like a great idea to me. It could make the content more accessible.

mre commented 2 months ago

Still open for PRs, but I'm closing this as it's technically not an issue with the project. Perhaps we can revisit this in the future.

zamazan4ik commented 2 months ago

Still open for PRs, but I'm closing this as it's technically not an issue with the project.

Then I suggest converting the issue into the Discussion (and moving to the "Ideas" section). It will be the better place for this activity since I agree with you - it's not a bug or something like that.

mre commented 2 months ago

Good idea!