diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-06-21 11:12:18 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-06-21 15:12:35 +0300 |
commit | 2383696d128d2c448ba5aca6a7fb3a688af11756 (patch) | |
tree | db160a6d018dfad2134bfd3fbe6e073698192e6f | |
parent | 632244d99c5a0080ff31ece43c0831a9ab192967 (diff) |
git: Always disable use of alternate refs for git-fetch(1)
While we know that git-fetch(1) is having issues when using alternate
refs, we currently only disable it when using `FetchInternal()`. Let's
globally disable usage of alternate refs so that we don't ever hit the
performance edge case when fetching into repositories which have an
object pool connected to them.
This fixes a performance regression in the FetchRemote RPC in case the
external configuration doesn't ask us to ignore alternate refs. In a
recent incident, latency of the RPC regressed from ~1s to ~90s per
invocation for forks of `gitlab-org/gitlab` when the external Git
configuration was removed.
Changelog: fixed
-rw-r--r-- | internal/git/command_description.go | 10 | ||||
-rw-r--r-- | internal/git/localrepo/remote.go | 8 |
2 files changed, 10 insertions, 8 deletions
diff --git a/internal/git/command_description.go b/internal/git/command_description.go index 6ca1ce76c..c0939a704 100644 --- a/internal/git/command_description.go +++ b/internal/git/command_description.go @@ -86,6 +86,16 @@ var commandDescriptions = map[string]commandDescription{ flags: 0, opts: append([]GlobalOption{ + // We've observed performance issues when fetching into big repositories + // part of an object pool. The root cause of this seems to be the + // connectivity check, which by default will also include references of any + // alternates. Given that object pools often have hundreds of thousands of + // references, this is quite expensive to compute. Below config entry will + // disable listing of alternate refs: they shouldn't even be included in the + // negotiation phase, so they aren't going to matter in the connectivity + // check either. + ConfigPair{Key: "core.alternateRefsCommand", Value: "exit 0 #"}, + // While git-fetch(1) by default won't write commit graphs, both CNG and // Omnibus set this value to true. This has caused performance issues when // doing internal fetches, and furthermore it's not encouraged to run such diff --git a/internal/git/localrepo/remote.go b/internal/git/localrepo/remote.go index b9d4428aa..53b1ce67e 100644 --- a/internal/git/localrepo/remote.go +++ b/internal/git/localrepo/remote.go @@ -128,14 +128,6 @@ func (repo *Repo) FetchInternal( commandOptions := []git.CmdOpt{ git.WithEnv(opts.Env...), git.WithStderr(opts.Stderr), - // We've observed performance issues when fetching into big repositories part of an - // object pool. The root cause of this seems to be the connectivity check, which by - // default will also include references of any alternates. Given that object pools - // often have hundreds of thousands of references, this is quite expensive to - // compute. Below config entry will disable listing of alternate refs: they - // shouldn't even be included in the negotiation phase, so they aren't going to - // matter in the connectivity check either. - git.WithConfig(git.ConfigPair{Key: "core.alternateRefsCommand", Value: "exit 0 #"}), git.WithInternalFetchWithSidechannel( &gitalypb.SSHUploadPackWithSidechannelRequest{ Repository: remoteRepo, |