Skip Git submodule update when possible #11486
Labels
A-git
Area: anything dealing with git
C-feature-request
Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Performance
Gotta go fast!
Problem
I'm working on a project which calls
cargo
multiple times during the course of a build. Each call tocargo
has overhead, even if it's not doing any work. I'd like to minimize that overhead.Doing some benchmarking, I notice that
GitCheckout::update_submodules
is a significant fraction of running time (17%).Here's the relevant portion of the statistics:
(please excuse the mangled symbols; this is a stock
cargo 1.65.0 (4bc8f24d3 2022-10-20)
)Proposed Solution
Right now, checking out submodules is done unconditionally in
GitDatabase::copy_into
.If we instead add it to
GitCheckout::reset
, we can ensure that submodules are checked out before the.cargo-ok
sentinel is created.Then, we can skip
update_submodules
entirely in cases where the sentinel is present.Notes
I have already implemented this in a branch here; the PR template suggested that I open an issue before a PR, but I'm happy to open a PR once I get approval.
With this patch, I see a 15% speedup in my build, and
GitDatabase::copy_to
is no longer doing significant work:The text was updated successfully, but these errors were encountered: