-
Notifications
You must be signed in to change notification settings - Fork 58
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
cargo could use a persistent hash map in it's resolver #6
Comments
I saw a reddit post about cargo's resolver and its performance and it reminded me of this. I decided to give this a go and I just now realized that you are the person posted that :) Anyway, I decided to give it a try and it seems to work fine. You can take a look at it here. I also did a very basic benchmark using rustc as an example and this is what I got:
This was measured with As you can see, in this basic benchmark, the performance of rpds is worse than before, but when using It is, however, planned for rpds to support both I would like to perform a more complex benchmark, which I saw you did (by looking at your reddit post). Can you tell me what you methodology was? |
Thanks for looking it this! That diff looks manageable to me. There are 2 benchmarks. The first is a "large but straight forward" test usually servo or rustc. This one can get faster or slower it is all ok, but it does need to be checked as it is really easy to make it 10x slower witch is unacceptable. The other test is how fast can it get to 10M ticks for a graf that it cannot resolve. Unfortunately, with rust-lang/cargo#5213 we are fresh out of examples of things that do not terminate. One alternative is to comment out the Also I wonder if the |
Also I usually got more targeted timing numbers with code like: if ticks % 1000000 == 0 {
let e = start.elapsed();
println!("{} ticks, {}s, {:.3} ticks/ms, {}, {}, {}",
ticks,
e.as_secs(),
ticks as f32 / (e.as_secs() as f32 * 1000.0),
cx.activations.iter().map(|x| x.1.len()).sum::<usize>(),
past_conflicting_activations.iter().map(|x| x.1.len()).sum::<usize>(),
remaining_deps.len(),
);
} added after !printed && ticks % 1000 == 0 |
Thank you for your tips! I did some further benchmarking and I'm going to document it here. First thing I need to say it that my previous benchmark is meaningless because it included network i/o and it was a single run. I added a new profiler to measure only the main resolver loop. I used this script to run the benchmark. I used 20 iterations.
These results are discouraging but I followed @Eh2406 suggestion and comment out the
So, there was only a small improvement here with I'm not ready to give up on this since there is at least on performance related improvements that might this worthwhile (#14). I will re-evaluate this when #14 lands. |
That is actually all very encouraging. As some background before rust-lang/cargo#5147 For the servo benchmark that +28% in Median Time is grate, the -22% on Average Time is concerning but the big question for the servo case is 10x regressions, so 3.2sec vs 2.6sec is probably ok. For the other case that is a +11% improvement. That is nothing to sneeze at, given all the work that has gone into optimizing the resolver. Sounds like it is worth talking to the cargo team (about adding the dependency) when #7 adds a way to use Definitely worth continued exploration of questions. How much difrants dose #14 make? Are there more |
In general it is hard to say, because it will depend on the amount of sharing in the data structures. There is one place where it is definitly going to be significantly faster (not sure if this piece of code runs a lot of times).
From a quick look it seems so! There is |
I am excited by this progress. Unfortunately I will not have time to look at my computer this weekend. |
orium/cargo@4007c38#diff-2305770923daa439ab4f47bb3f1abf5cR372 Since the keys and values stored in the hashmaps are |
Ok, hear is how I see it from reading this thread. @orium has demonstrated that the diff to mvp of Once we have the mvp, there is low hanging fruit. #7 (comment), and #14 on the rpds side and moving more structures on the cargo side. |
Closing since cargo is now using |
Hi,
I was reviewing the code in cargo's resolver when I came across this line:
"We should switch to persistent hash maps if we can..."
and thought didn't I just see a persistent hash map crate.
So if/when this crate is ready, perhaps a pr thare?
Just my 2c.
The text was updated successfully, but these errors were encountered: