]> git.proxmox.com Git - cargo.git/commit - src/doc/src/commands/cargo-doc.md
Auto merge of #10079 - dtolnay-contrib:fetch, r=ehuss
authorbors <bors@rust-lang.org>
Fri, 24 Jun 2022 19:25:13 +0000 (19:25 +0000)
committerbors <bors@rust-lang.org>
Fri, 24 Jun 2022 19:25:13 +0000 (19:25 +0000)
commitdbff32b27893b899ae2397f3d56d1be111041d56
tree6daba2c747d206e9f9992c6ca9f91cb23d8acdae
parent47620e20604fe53097ff7125806eaf38c840a18b
parent7da3c360bc82021e0daf93dba092628165375456
Auto merge of #10079 - dtolnay-contrib:fetch, r=ehuss

Fetch GitHub commits by long hash more efficiently

Closes #10078.

**Tested with the following Cargo.toml:**

```toml
[package]
name = "repro"
version = "0.0.0"
edition = "2021"
publish = false

[dependencies]
cargo = { git = "https://github.com/rust-lang/cargo", rev = "b30694b4d9b29141298870b7993e9aee10940524" }
```

```console
$ rm -rf ~/.cargo/git/db/cargo-* ~/.cargo/git/checkouts/cargo-*
$ time $CARGO generate-lockfile
$ du -shc ~/.cargo/git/db/cargo-* ~/.cargo/git/checkouts/cargo-*
```

Using current cargo from the most recent nightly, the `generate-lockfile` command downloads 69704 git objects in 7.0 seconds, consuming 41 MB on disk.

Using cargo built from this PR by `cargo build --release`, the same command downloads 21481 objects in 2.2 seconds, consuming 17 MB on disk.

Once libgit2 is able to do shallow clones (https://github.com/libgit2/libgit2/issues/3058) this can be even more of a speedup. Using command-line git (which does not use libgit2) and `time git fetch --depth=1 https://github.com/rust-lang/cargo b30694b4d9b29141298870b7993e9aee10940524` indicates that it downloads just 262 objects in 1.1 seconds.