-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Summary
RFC: #2789
Implementation: #10470
Documentation: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#sparse-registry
Issues:
A-sparse-registry
This is a tracking issue for RFC #2789, an experimental extension to serve the index over HTTP instead of via git.
Unresolved issues
- Cache invalidation
- Currently 1 minute TTL. Too long for publish, too short for effective caching.
- Minor concern about how long an invalidation takes (Cloudfront says 10 to 100 seconds)
- The cost is expected to negligible.
To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel. - Make
sparse+andregistry+more consistent. HTTP registry implementation #10470 (comment) (resolved Add new SourceKind::SparseRegistry to differentiate sparse registries #11209) - Find a better name (and structure) for
index_versionHTTP registry implementation #10470 (comment) - Handle user urls that start with
http. They currently implyregistry+. But ifsparse+are more common then it would be good to auto detect. RFC: Serve crates-io registry over HTTP as static files rfcs#2789 (comment) - Have a plan for lockfiles.
- Implement support in crates.io Upload index metadata to
index/when publishing new crates crates.io#4661 - Check that crates.io is willing to maintain their current system at production levels of traffic.
- Teach cargo that crates.io has two equivalent indexes. Teach cargo that crates.io has two equivalent indexes. #10722
- Make sure we are future compatible with a merkle tree design. Sparse registry indexes should be viewable atomically #10928
- The RFC is intentionally sparse on details, it is almost an eRFC. Do we need another RFC/PR to discuss the details we have chosen?
Does not support fuzzy queries. Is that a blocker? Only used by error messages.This was a misunderstanding, indexes don't support name-based typo suggestions at all. Sparse supports the same case-folding and-/_fuzzy comparison as git indexes. Sparse fundamentally won't be able to support typo suggestions, but since cargo hasn't handled that in the past, this isn't a regression, and more like a "can't do that in the future" thing.- Investigate publish issues. 1 minute update is quite slow if publishing multiple packages (and cargo does not yet have retry logic).
To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Current best way to test
To try it out, add the -Z sparse-registry flag on nightly-2022-06-20 or newer build
of Cargo. For example, to update dependencies:
rustup update nightly
cargo +nightly -Z sparse-registry update
The feature can also be enabled by setting the environment variable
CARGO_UNSTABLE_SPARSE_REGISTRY=true. Setting this variable will have no effect on stable
Cargo, making it easy to opt-in for CI jobs.
If you see any issues please report them in new tickets here in the Cargo repo. The output of Cargo
with the environment variable CARGO_LOG=cargo::sources::registry::http_remote=trace set
will be helpful in debugging.
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Implementation history
-
Registry functions return Poll to enable parallel fetching of index data #10064
-
Refactor RegistryData::load to handle management of the index cache #10482
-
Make -Z http-registry use index.crates.io when accessing crates-io #10725
-
Fix sparse registry lockfile urls containing 'registry+sparse+' #11177
-
Add new SourceKind::SparseRegistry to differentiate sparse registries #11209
-
Add configuration option for controlling crates.io protocol #11215
-
Upload index metadata to
index/when publishing new crates crates.io#4661 -
Drop index/ prefix when uploading crate metadata. crates.io#4826
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Activity
[patch](and[replace]) sections in Cargo config. #5539[-]Tracking Issue for servering an index over HTTP[/-][+]Tracking Issue for serving an index over HTTP[/+]mightyiam commentedon Jun 22, 2022
Hey, would this mean that when
cargo publishexits with 0 the published crate version is actually available (which is not the case now, due to CDN)?kornelski commentedon Jun 22, 2022
It doesn't address this problem. There is still going to be a delay between
cargo publishand the crate being available globally. It would be nice to improve this, but it's more of an issue for server-side crates-io implementation than the registry protocol.epage commentedon Jun 22, 2022
@mightyiam #9507 is the issue you want to be following.
For background, publishing a crate used to be a blocking operation but to speed up crates.io, they made
cargo publishjust put the crate into a queue for later publishing, making the operation asynchronous.Tools like cargo-release poll the server. We could easily do similar in cargo until an improved registry protocol is made. I was looking at implementing it but there was a large hurdle for writing the relevant tests. The new sparse registry code has improved the test infrastructure so I could now write the relevant tests.
40 remaining items
cargoto use thesparseprotocol for registry access cisagov/code-gov-update#38sparse-registryintellij-rust/intellij-rust#10267Christoph-AK commentedon Mar 23, 2023
I'm super glad this got merged, but I am having trouble finding the necessary config steps to enable the new behaviour.
Most of the documentation, like in the first post in this issue, still mention it as unstable feature to be enabled with -Z.
Adding
[registries.crates-io] protocol = sparseto my cargo.toml doesn't work, i suppose it needs to be added to some cargo config file somewhere else.Could someone that got it running write some annotations or documentation in some easy to find places?
JockeTF commentedon Mar 23, 2023
Agreed, this is a great feature! According to the release notes you're supposed to add the setting to
.cargo/config.toml, notCargo.toml. Either that, or set the environment variableCARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse. The release notes have some links to more information as well!Implement Cargo HTTP index (#24452)
jose-mut-lopez commentedon Jun 19, 2023
thanks for this and those links, but for future outsider readers like me, it looks like this became the default in cargo 1.70 which was released on June 2023 (https://blog.rust-lang.org/2023/06/01/Rust-1.70.0.html#sparse-by-default-for-cratesio), so a better approach now IMO is just to
rustup update, which will use the fast index on all repos by default without any per-repo config.