-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Speedup ripgrep using profile guided optimization #1225
Comments
Neat. Could you please document the build dependencies here more thoroughly? Whether this is done or not almost completely depends on how much of a hassle it would be to add to the release process. |
I just checked this against alpine since it is used in .travis.yaml. The package llvm-dev would be required. The main problem is that |
Thanks for suggesting this. I just briefly tried this out, and while I could get it to work, I couldn't really see any noticeable performance improvement. Moreover, this would complicate and prolong the release process by quite a bit. Not only does ripgrep need to be built twice, but it needs to get some sizable corpus on which to search a number of times. Overall, I don't think it's worth it. |
As of Rust 1.37, PGO is stable. |
I didn't finish all the tests but I already have some preliminary results. On my Linux machine (Fedora 39, AMD Ryzen 5900x with disabled Turbo boost, 48 Gib RAM, Rust 1.74, with
where:
As a PGO training set, I used Ripgrep's benchsuite. Right now I cannot provide you with all the results since on my machine for some unknown yet reasons the provided I ran several other commands from the bench suite - the performance improvements were near the same in the tested-by-me cases. I specially built ripgrep without I have some thoughts about these results:
5-10% improvement for some people is really important. My main use-case for that - (rip)grepp'ing hundreds of logs on our log storage nodes with some non-trivial patterns. Some queries could run for tens of minutes/hours, and even a few percent of performance is definitely worth it (even if we need to recompile ripgrep - it's not a problem). @BurntSushi Should I create a separate issue/discussion for the topic? |
The idea is to build ripgrep with as much optimization as possible. This makes compilation times absolutely obscene. They jump from <10 seconds to 30+ seconds on my i9-12900K. I don't even want to know how long CI would take with these. I tried some ad hoc benchmarks and could not notice any meaningful improvement with the LTO binary versus the normal release profile. Because of that, I still don't think it's worth bloating the release cycle times. Ref #1225
@zamazan4ik See b6bac84 Basically, I'm still not convinced. I only tested LTO and not PGO, but PGO does not sound like something I'm keen on maintaining. In any case, I've at least added a |
Request for improvement
What version of ripgrep are you using?
compiled current master (0913972)
How did you install ripgrep?
compiled current master (0913972)
What operating system are you using ripgrep on?
Linux Mint 19.1 with kernel 4.18.0-16-lowlatency
Describe your question, feature request, or bug.
Profile guided optimization works by building the binary with profiling instrumentation first, then running the instrumented binary in a few test cases while saving runtime profiles and then using the profiles to optimize the code for example by reordering functions to improve cachability.
Using the very naive benchmark
time sudo target/release/rg --with-filename --word-regexp --line-buffered a /home > /dev/null
ripgrep needed3.7s
on avg without profile guided optimization on my system and3.3s
with pgo.This is how I compiled rg with pgo:
pgo could speed up ripgrep quite a bit when done correctly.
The text was updated successfully, but these errors were encountered: