Leverage local links on git checkouts
authorAlex Crichton <alex@alexcrichton.com>
Mon, 8 Jan 2018 17:38:40 +0000 (09:38 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 8 Jan 2018 17:38:40 +0000 (09:38 -0800)
commit5cca4e8c2496a1925a549c26c02ad11dd105c7a4
treec7ec3564bd9f8d5ee11689d76b4b0445356c80ae
parent33f08cb83a5cbad7fb1024e98c7acb4e19a93456
Leverage local links on git checkouts

This commit updates the handling of git checkouts from the database to use
hardlinks if possible, speeding up this operation for large repositories
significantly.

As a refresher, Cargo caches git repositories in a few locations to speed up
local usage of git repositories. Cargo has a "database" folder which is a bare
checkout of any git repository Cargo has cached historically. This database
folder contains effectively a bunch of databases for remote repos that are
updated periodically.

When actually building a crate Cargo will clone this database into a different
location, the checkouts folder. Each rev we build (ever) is cached in the
checkouts folder. This means that once a checkout directory is created it's
frozen for all of time.

This latter step is what this commit is optimizing. When checking out the
database onto the local filesystem at a particular revision. Previously we were
instructing libgit2 to fall back to a "git aware" transport which was
exceedingly slow on some systems for filesystem-to-filesystem transfers. This
optimization (we just forgot to turn it on in libgit2) is a longstanding one and
should speed this up significantly!

Closes #4604
Cargo.toml
src/cargo/sources/git/source.rs
src/cargo/sources/git/utils.rs