docs: Update performance.md#188
Conversation
zamazan4ik
commented
Oct 2, 2024
- add documentation about PGO usage for optimizing Rinja's performance. As was asked in https://www.reddit.com/r/rust/comments/1ftx5iv/comment/lpy5v01/
- add documentation about PGO usage for optimizing Rinja's performance
|
|
||
| ## Profile-Guided Optimization (PGO) | ||
|
|
||
| To optimize Rinja's performance, you can compile your application with [Profile-Guided Optimization](https://doc.rust-lang.org/rustc/profile-guided-optimization.html). According to the [tests](https://github.com/mitsuhiko/minijinja/pull/588#issuecomment-2387957123), PGO can improve the library performance by 15%. |
There was a problem hiding this comment.
We write rinja in lowercase so please update. :)
Could you also explain in the book directly instead of linking to a github issue? The explanations there are great so I think you can mostly copy-paste it as is.
There was a problem hiding this comment.
We write rinja in lowercase so please update. :)
Sorry - I just copied it from line 30th "... Rinja's derive macros" ;)
Could you also explain in the book directly instead of linking to a github issue? The explanations there are great so I think you can mostly copy-paste it as is.
Sure. Which details should be copied from the GitHub issue to the book? Just asking because I am sure that you don't need all the details (like my test env). Better clarify upfront then rework multiple times.
There was a problem hiding this comment.
Anything needed to be able to use PGO. What you need to install etc.
There was a problem hiding this comment.
Instructions about how to use PGO for Rust programs are described in the official Rustc docs that I already linked to the docs: https://doc.rust-lang.org/rustc/profile-guided-optimization.html - it's an official instruction about how to implement PGO for Rust programs (including a note about about cargo-pgo). My GitHub issue describes how to reproduce my benchmark results. I guessed that target users are not interested in reproducing my benchmarks but interested in optimizing their rinja-based apps.
There was a problem hiding this comment.
So maybe just remove the GitHub link at all from the docs? :)
|
Interesting! @zamazan4ik, do you know if it's possible to see/evaluate the results of the profiling? If it is, then maybe we could add a few |
Well, it's possible to achieve via analyzing "before" vs "after" assembly LLVM IR and guessing the required changes (or extracting optimization feedback from LLVM). However, I highly recommend don't do it in practice since this way has many drawbacks:
So my personal recommendation is just leaving the things to PGO and spend your efforts to something more important to the projects like high-level/algortihm optimizations that still cannot be done by compilers (at least yet). |
|
You didn't update "Rinja" to lowercase and now it's called "askama" too. :) |
|
Ahh, okay - if it's the only required change - I'll do it. |
|
Thanks! |