Commit dbff32b
committed
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 (libgit2/libgit2#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 b30694b` indicates that it downloads just 262 objects in 1.1 seconds.1 file changed
+14
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
815 | 815 | | |
816 | 816 | | |
817 | 817 | | |
| 818 | + | |
818 | 819 | | |
819 | 820 | | |
| 821 | + | |
| 822 | + | |
820 | 823 | | |
821 | 824 | | |
822 | 825 | | |
| |||
1036 | 1039 | | |
1037 | 1040 | | |
1038 | 1041 | | |
1039 | | - | |
| 1042 | + | |
1040 | 1043 | | |
1041 | 1044 | | |
1042 | 1045 | | |
| |||
1047 | 1050 | | |
1048 | 1051 | | |
1049 | 1052 | | |
| 1053 | + | |
| 1054 | + | |
1050 | 1055 | | |
1051 | 1056 | | |
1052 | 1057 | | |
| |||
1089 | 1094 | | |
1090 | 1095 | | |
1091 | 1096 | | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
0 commit comments