-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Resolving deltas takes long time #11014
Comments
Hi. Supposed your are talking about updating crates.io index, such like this
It is a known issue and the community are working on this from different angles. First, Cargo introduced a unstable feature called sparse index, which is tracked here1. It provides a new way to fetch crate dependencies on demand, without downloading the whole index up front. Please check its doc and help us improve and push it to stable! The other approach is a speedup of Git itself. We're going to do experiments on replacing some of git2 functionality in Cargo with gitoxide, which is a more modular, safer, and faster Git implementation in Rust. This doesn't remove the entire "resolve deltas" phase but does accelerate it, not to mention the long lingering performance issue about shallow clone2 and local index3 being fixed. In the meanwhile, you can use I am going to close this as each approach has already been tracked by other issues. Thank you for the report! Footnotes |
@weihanglo that's a good news, thank you for your reply. |
Just hit this today via
I've to change it to
to see what going on and seem like I get stuck at
for a long waiting time, then i try again and get
yet another long waiting time, maybe after update |
Also experiencing this. Cargo should be using a global anycast HA endpoint something other than leaning on github. It should be minimal, binary, versioned, differential transformations, compressed, authenticated, continuable, and performant... not git. Wasting my life waiting for tens of KiB to populate at a time. I could be wrong, but I believe it's hitting GH's API tarpit throttling code or there's some network storm going on. |
Maybe it's a local Github country mirror issue, my main one is the deltas part. Everything else is okay, but AU is offpeak. I get around 30-90mb/s to Github. |
In addition to the fixes mentioned above delete |
Apparently the index normalization was done today. Which means that today's delta includes a change of almost every file. |
This comment was marked as outdated.
This comment was marked as outdated.
Some good news:
|
Sparse registry is now the default for crates.io in 1.70. I would say this is largely resolved. Close and thanks everyone. |
Does anyone have a suggested fix for this on older Rust versions? I'm currently trying to test on my crate's MSRV (1.57), and so the more recent Cargo fixes aren't available. I believe what I'm seeing is a download issue because there's no "resolving deltas" message printed, but I keep getting network timeouts to GitHub despite my other network traffic behaving as normal. It's timed out multiple times, meaning I literally am unable to update the index, and so I can't compile, period. Has anyone figured out a workaround for the network part of this (notably on older versions of Cargo)? |
Here is something you can try:
That will fetch all objects you are missing, so next time Please let me know how it goes and good luck! |
Okay I'll try that, thanks! EDIT: A few hours after I posted my comment, network conditions improved and I was able to download the index successfully. I tried this anyway, and it worked, although I'm not sure what that tells me since the problem had resolved itself (presumably transiently). Your suggestion did work, at least 🤷♂️ |
Problem
Cargo can be very slow updating the crates.io index. You may see a progress bar such as:
Workaround
There are three different workarounds for this issue. The following instruction assume that
CARGO_HOME
is the default of.cargo
in your home directory.Use net.git-fetch-with-cli
The
net.git-fetch-with-cli
config option will instruct cargo to use thegit
CLI to update the index instead of its built-in git client. Thegit
CLI should be more efficient at updating the repository. Enter the following into your global cargo configuration file, usually~/.cargo/config.toml
(or~/.cargo/config
for older setups):Or set the environment variable
CARGO_NET_GIT_FETCH_WITH_CLI=true
.Delete the index cache
To work around this issue, delete the existing git index in cargo's cache. This will cause cargo to re-download the index which should have minimal deltas to resolve.
For most users, the following should be sufficient:
rm -rf ~/.cargo/registry/index
For Powershell users:
For Windows cmd users:
Switch to the sparse protocol
In the 1.68 release of Rust, you can opt-in to the new sparse protocol. This uses HTTPS instead of git to update the index, which should be much more efficient in most cases. In your global
~/.cargo/config.toml
file, enter:Or set the
CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
environment variable.Cause
Cargo uses the libgit2 library for handling git operations. Its "delta resolution" algorithm has some inefficiencies, particularly when updating an existing repository that has a chain of historic updates. This issue is tracked upstream in libgit2/libgit2#4674.
Solutions
There are several approaches that the Cargo Team is investigating for resolving this:
gitoxide
for git operations.The text was updated successfully, but these errors were encountered: