Skip to content

git: Skip checks whether a fetch is updating submodules

Patrick Steinhardt requested to merge pks-git-fetch-dont-recurse-submodules into master

When fetching into a repository, Git will by default check whether the fetch brings in any commits which update a submodule. If so, and if that submodule is populated, then we'll recurse into that submodule and also perform a fetch in there. This is useless though in our context because we never populate submodules, so computing whether there are commits which update any submodule is a complete waste of time.

The following mirror-fetch has been executed in www-gitlab-com:

Benchmark 1: git fetch --recurse-submodules=on-demand +refs/*:refs/*
  Time (mean ± σ):     66.595 s ±  1.396 s    [User: 63.019 s, System: 8.729 s]
  Range (min … max):   65.377 s … 68.118 s    3 runs

Benchmark 2: git fetch --recurse-submodules=no +refs/*:refs/*
  Time (mean ± σ):     62.789 s ±  1.202 s    [User: 61.434 s, System: 7.774 s]
  Range (min … max):   61.621 s … 64.022 s    3 runs

Summary
  'git fetch --recurse-submodules=no +refs/*:refs/*' ran
    1.06 ± 0.03 times faster than 'git fetch --recurse-submodules=on-demand +refs/*:refs/*'

This demonstrates that we get a nice small speedup by explicitly disabling the check.

Closes #4071 (closed)

Merge request reports