-
Notifications
You must be signed in to change notification settings - Fork 114
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 #26
Comments
Heh, in fact the original For me, it'd be really interesting to see if the API is there yet for real world problems like this - I might actually give it a go before I tag the next major release, there's probably a lot of valuable learning to be had from doing this before I settle on a stable API. |
Using
I'd be happy to help anyway I can! For most projects, I'd add a dependency without asking the dependency for permission. But for inclusion in the oficial Rust distribution, I just wanted to make sure you are willing to get the extra attention that may bring.
I have asked other persistence libraries in the past and they have found it a useful exercise. They decided that there API was not quite ready.
|
Yes, basically I've got your first two items already in released versions, and the other two are already done in unreleased code. And yes, this is a full time work project for me currently, I can definitely cope with the extra attention. 😊 |
Wonderful to hear! So I did a quick audit of I'd start with that Another approach is a quick audit of |
Working from master the diff is very small to get Edit: Converting |
Update here: I've stabilised the API and am about ready to release - I didn't actually have this thread in mind when working on it, but it looks like I've accidentally managed to address the rough bits you mentioned, probably because I've modelled the final API very closely on std::collections. I've run the API through a couple of local projects, and it seems sound enough, and looking at the Cargo code I think a port should be very straightforward, so I think I'm going to go ahead and tag the release after agonising about it for just a little while longer. |
Thanks the new api looks good! I really like the One small thing, features are global and additive. So if I rely on |
Good call on the feature, I've changed it to |
Persistent data structures by im-rs There has been a long standing "TODO: We should switch to persistent hash maps if we can" in the resolver. This PR introduces a dependency on [im-rs](bodil/im-rs#26) to provide persistent hash maps. It then uses `im_rc::OrdSet` to store the priority list of dependencies, instead of `std::BinaryHeap`, as cloning the `Heap` was one of the most expensive things we did. In Big O terms these changes are very big wins, in practice the improvement is small. This is do to a number of factors like, `std::collections` are very fast, N is usually only in the hundreds, we only clone when the borrow checker insists on it, and we use `RC` and other tricks to avoid cloning. I would advocate that we accept this PR, as: - Things are only going to get more complicated in the future. It would be nice to have Big O on our side. - When developing a new feature finding each place to add `RC` should be an afterthought not absolutely required before merge. (cc #6129 witch is stuck on this kind of per tick performance problem as well as other things). - As the code gets more complex, making sure we never break any of the tricks becomes harder. It would be easier to work on this if such mistakes are marginal instead of show stoppers. (cc #5130 a bug report of one of these bing removed and affecting `./x.py build` enough to trigger an investigation). - The resolver is already very complicated with a lot of moving parts to keep in your head at the same time, this will only get worse as we add features. There are a long list of tricks that are *critical* before and `~5%` after, it would be nice to consider if each one is worth the code complexity. (I can list some of the ones I have tried to remove but are still small wins, if that would help the discussion). Overall, I think it is worth doing now, but can see that if is not a slam dunk.
Cargo is now using |
Hi,
Cargo's resolver has a long standing
TODO
:"We should switch to persistent hash maps if we can..."
So when I watched your talk at RustFest Paris I thought I'd make the introductions. So if/when this crate is ready, perhaps a pr thare?
The comment is somewhat out of date. Thanks to a lot of profiling most things are wrapped in
RC
/ARC
and are bespoke custom persistent data structures. So I suspect it will improve ergonomics more then speed, but I'd be happy to be wrong.The text was updated successfully, but these errors were encountered: