diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-01-28 14:06:20 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-01-28 14:06:20 +0300 |
commit | 512bf0f683df32b18c5eb8944176f5128f1a0ffc (patch) | |
tree | d15fd0822342bc56d66249c969295480fb2cfe31 | |
parent | 69baea2ed2c593ed570b614f1c311d8ee80a1c33 (diff) |
repository: Use skipping negotiation algorithm for replication
When doing reference negotiation, client and server try to come up with
common references. When branches are not at the same commit, the
negotiatior tries to go through the commit chain to come up with older
commits which are in common. This can take quite some time though in
case there have been many new commits on the server side.
Git has thus introduced a new "skipping" negotiation algorithm. This
algorithm has the goal of converging faster by skipping commits in
Fibonacci sequences such that we skip commits increasingly faster. The
downside is that the negotiated packfile is like larger, but the upside
is that we can conclude the reference negotiation phase faster. Given
that we have seen in production that negotiation is what dominates
replication times in repositories with huge references this tradeoff
seems worth it.
Convert our replication to use "skipping" negotiation.
Changelog: performance
-rw-r--r-- | internal/gitaly/service/repository/replicate.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/internal/gitaly/service/repository/replicate.go b/internal/gitaly/service/repository/replicate.go index 427bc8a4a..13b96cf37 100644 --- a/internal/gitaly/service/repository/replicate.go +++ b/internal/gitaly/service/repository/replicate.go @@ -14,6 +14,7 @@ import ( "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus" "gitlab.com/gitlab-org/gitaly/v14/client" "gitlab.com/gitlab-org/gitaly/v14/internal/command" + "gitlab.com/gitlab-org/gitaly/v14/internal/git" "gitlab.com/gitlab-org/gitaly/v14/internal/git/localrepo" "gitlab.com/gitlab-org/gitaly/v14/internal/git/remoterepo" "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/storage" @@ -231,7 +232,13 @@ func fetchInternalRemote( ctx, remoteRepoProto, []string{mirrorRefSpec}, - localrepo.FetchOpts{Prune: true, Stderr: &stderr}, + localrepo.FetchOpts{ + Prune: true, + Stderr: &stderr, + CommandOptions: []git.CmdOpt{ + git.WithConfig(git.ConfigPair{Key: "fetch.negotiationAlgorithm", Value: "skipping"}), + }, + }, ); err != nil { if errors.As(err, &localrepo.ErrFetchFailed{}) { return fmt.Errorf("fetch: %w, stderr: %q", err, stderr.String()) |