Skip to content

Commit 32684fd

Browse files
authored
Merge pull request #990 from arlosi/http-registry
Add post to call for testing of Cargo's -Z sparse-registry
2 parents 870c018 + ebe109b commit 32684fd

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
layout: post
3+
title: "Call for testing: Cargo sparse-registry"
4+
author: Arlo Siemsen
5+
team: The Cargo Team <https://www.rust-lang.org/governance/teams/dev-tools#cargo>
6+
---
7+
8+
The Cargo nightly [`sparse-registry`][sparse-registry] feature is ready for testing. The
9+
feature causes Cargo to access the crates.io index over HTTP, rather than git. It can
10+
provide a significant performance improvement, especially if the local copy of
11+
the git index is out-of-date or not yet cloned.
12+
13+
## Overview
14+
To try it out, add the `-Z sparse-registry` flag on a recent nightly build of Cargo.
15+
For example, to update dependencies:
16+
17+
```
18+
rustup update nightly
19+
cargo +nightly -Z sparse-registry update
20+
```
21+
22+
The feature can also be enabled by setting the environment variable
23+
`CARGO_UNSTABLE_SPARSE_REGISTRY=true`. Setting this variable will have no effect on stable
24+
Cargo, making it easy to opt-in for CI jobs.
25+
26+
The minimum Cargo version is `cargo 2022-06-17`, which is bundled with `rustc 2022-06-20`.
27+
28+
You can [leave feedback on the internals thread][internals].
29+
30+
If you see any issues [please report them on the Cargo repo][cargo]. The output of Cargo
31+
with the environment variable `CARGO_LOG=cargo::sources::registry::http_remote=trace` set
32+
will be helpful in debugging.
33+
34+
## Details
35+
36+
Accessing the index over HTTP allows crates.io to continue growing without hampering
37+
performance. The current git index continues to grow as new crates are published,
38+
and clients must download the entire index. The HTTP index only requires downloading
39+
metadata for crates in your dependency tree.
40+
41+
The performance improvement for clients should be especially noticeable in CI
42+
environments, particularly if no local cache of the index exists.
43+
44+
On the server side, the HTTP protocol is much simpler to cache on a CDN, which improves
45+
scalability and reduces server load. Due to this caching, crate updates may take an
46+
extra minute to appear in the index.
47+
48+
The Cargo team plans to eventually make this the default way to access crates.io
49+
(though the git index will remain for compatibility with older versions of Cargo and
50+
external tools). `Cargo.lock` files will continue to reference the existing crates.io
51+
index on GitHub to avoid churn.
52+
53+
The `-Z sparse-registry` flag also enables alternative registries to be accessed over
54+
HTTP. For more details, see the [tracking issue][tracking-issue].
55+
56+
## Thank you
57+
58+
This project has been in the works for over 2.5 years with collaboration from the crates.io,
59+
infra, and Cargo teams.
60+
61+
[@kornelski](https://github.com/kornelski) wrote the [sparse-index RFC][rfc] and initial
62+
performance proof of concept. [@jonhoo](https://github.com/jonhoo) created the initial
63+
implementation in Cargo and gathered performance data. [@arlosi](https://github.com/arlosi)
64+
completed the implementation in Cargo and implemented the changes to crates.io to serve the
65+
index. [@eh2406](https://github.com/eh2406) provided numerous reviews and feedback to get
66+
all the changes landed. Many others from the community helped by providing suggestions,
67+
feedback, and testing.
68+
69+
Thank you to everyone involved!
70+
71+
[rfc]: https://rust-lang.github.io/rfcs/2789-sparse-index.html
72+
[sparse-registry]: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#sparse-registry
73+
[internals]: https://internals.rust-lang.org/t/call-for-testing-cargo-sparse-registry/16862
74+
[tracking-issue]: https://github.com/rust-lang/cargo/issues/9069
75+
[cargo]: https://github.com/rust-lang/cargo/issues

0 commit comments

Comments
 (0)