Skip to content

Commit 682cd8e

Browse files
authored
Merge pull request #1069 from ehuss/cargo-sparse-testing
Post about testing Cargo's sparse registry
2 parents 9964a33 + 3a60ae1 commit 682cd8e

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

posts/2022-06-22-sparse-registry-testing.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ author: Arlo Siemsen
55
team: The Cargo Team <https://www.rust-lang.org/governance/teams/dev-tools#cargo>
66
---
77

8+
> Note: Sparse registry support has been stabilized for the 1.68 release.
9+
> See [Help test Cargo's new index protocol](../../../inside-rust/2023/01/30/cargo-sparse-protocol.html) for updated information.
10+
811
The Cargo nightly [`sparse-registry`][sparse-registry] feature is ready for testing. The
912
feature causes Cargo to access the crates.io index over HTTP, rather than git. It can
1013
provide a significant performance improvement, especially if the local copy of
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
layout: post
3+
title: Help test Cargo's new index protocol
4+
author: Eric Huss
5+
team: The Cargo Team <https://www.rust-lang.org/governance/teams/dev-tools#cargo>
6+
---
7+
8+
Cargo's new index protocol will be available starting in Rust 1.68, which will be released on 2023-03-09.
9+
This new "sparse" protocol should usually provide a significant performance improvement when accessing [crates.io].
10+
11+
We would like your help in testing this new feature and infrastructure.
12+
If you use beta (1.68) or nightly-2023-01-21 or newer, set the environment variable `CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse`, or edit your [`.cargo/config.toml` file](https://doc.rust-lang.org/cargo/reference/config.html) to add:
13+
14+
```toml
15+
[registries.crates-io]
16+
protocol = "sparse"
17+
```
18+
19+
We would like to hear reports on your experience.
20+
If you run into a problem, please [open an issue](https://github.com/rust-lang/cargo/issues/new?assignees=&labels=C-bug&template=bug_report.yml).
21+
If you would like to post general feedback, feel free to leave a message on [this internals thread](https://internals.rust-lang.org/t/cargo-sparse-protocol-feedback-thread/18234).
22+
23+
Along with fetching crates and running `cargo update`, we'd also like to hear if you have any issues when running `cargo publish`.
24+
Another data point that may be helpful is to gauge how many users are behind a restrictive firewall, proxy, or other network environment that prevents access to the index.
25+
26+
This new service will be opt-in as we roll it out and gather information about how it performs.
27+
In the near future we intend to switch to this as the default.
28+
29+
## Background
30+
31+
In order for Cargo to determine which crates exist on [crates.io], it downloads and reads an "index" which lists all versions of all crates.
32+
The index lives in a [git repository](https://github.com/rust-lang/crates.io-index/) hosted on GitHub.
33+
Cargo fetches and stores the index in Cargo's home directory.
34+
This system lets GitHub handle the server-side processing, and provides a convenient way to incrementally fetch new updates.
35+
36+
However, as the index has grown considerably over time, this system has started to hit scaling limitations, and initial fetches and updates continue to slow down. You may have noticed a pause when Cargo displays `Updating crates.io index` or while going through the "resolving deltas" phase:
37+
38+
```
39+
Updating crates.io index
40+
Fetch [=================> ] 74.01%, (64415/95919) resolving deltas
41+
```
42+
43+
With [RFC 2789](https://rust-lang.github.io/rfcs/2789-sparse-index.html), we introduced a new protocol to improve the way Cargo accesses the index.
44+
Instead of using git, it fetches files from the index directly over HTTPS.
45+
Cargo will only download information about the specific crate dependencies in your project.
46+
47+
We have introduced a new service at `https://index.crates.io/` for hosting the [crates.io] index.
48+
If you are behind a restrictive firewall or proxy, you may need to explicitly allow Cargo to access this site.
49+
50+
More information about how the index and this new sparse protocol works can be found in [the documentation](https://doc.rust-lang.org/nightly/cargo/reference/registry-index.html#index-protocols).
51+
52+
The [crates.io] git repository will continue to be the source of truth for the index, and Cargo will continue to support git indexes indefinitely.
53+
54+
## Acknowledgements
55+
56+
We would like to give a huge show of gratitude to [Arlo Siemsen](https://github.com/arlosi) who implemented this feature and went to great lengths to bring it to completion.
57+
We would also like to thank the [crates.io team](https://www.rust-lang.org/governance/teams/crates-io) and the [infrastructure team](https://www.rust-lang.org/governance/teams/infra) for implementing, reviewing, and supporting this endeavor.
58+
We would also like to acknowledge the generosity of [GitHub](https://github.com/) for hosting the crates.io index over the past 8 years.
59+
60+
[crates.io]: https://crates.io

0 commit comments

Comments
 (0)