Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-03-29 08:59:55 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-03-29 09:15:01 +0300
commitb2d62949e1855d4b72a39818fc09250365f230dd (patch)
treeb2c30d8cdebbb95272365013c54936482d5e1760 /internal/gitaly/service
parentcc42cf8f28dc37bf808dabaac8a055a84b83a5db (diff)
git: Globally limit threads used by git-pack-objects(1)
By default, git-pack-objects(1) will spawn as many threads as there are logical CPU cores on the machine. While this typically makes sense on a client's machine because a client will want the command to finish as fast as possible, on the server-side this is less of a good idea because it can easily impact other, concurrently running Git commands. This is why we have started to limit the number of threads this command may use when performing repository maintenance. Packing of objects is in no way limited to maintenance though, but it's also executed e.g. when serving packfiles. Let's globally limit the number of threads git-pack-objects(1) uses by injecting the `pack.threads` configuration into all commands which may generate packfiles. Changelog: performance
Diffstat (limited to 'internal/gitaly/service')
-rw-r--r--internal/gitaly/service/repository/repack.go10
-rw-r--r--internal/gitaly/service/repository/repack_test.go22
2 files changed, 0 insertions, 32 deletions
diff --git a/internal/gitaly/service/repository/repack.go b/internal/gitaly/service/repository/repack.go
index 18415d4ba..6ba97185d 100644
--- a/internal/gitaly/service/repository/repack.go
+++ b/internal/gitaly/service/repository/repack.go
@@ -3,11 +3,9 @@ package repository
import (
"context"
"fmt"
- "math"
"github.com/prometheus/client_golang/prometheus"
gitalyerrors "gitlab.com/gitlab-org/gitaly/v14/internal/errors"
- "gitlab.com/gitlab-org/gitaly/v14/internal/git"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/housekeeping"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
@@ -25,14 +23,6 @@ func init() {
prometheus.MustRegister(repackCounter)
}
-// log2Threads returns the log-2 number of threads based on the number of
-// provided CPUs. This prevents repacking operations from exhausting all
-// available CPUs and increasing request latency
-func log2Threads(numCPUs int) git.ValueFlag {
- n := math.Max(1, math.Floor(math.Log2(float64(numCPUs))))
- return git.ValueFlag{Name: "--threads", Value: fmt.Sprint(n)}
-}
-
func (s *server) RepackFull(ctx context.Context, in *gitalypb.RepackFullRequest) (*gitalypb.RepackFullResponse, error) {
if in.GetRepository() == nil {
return nil, helper.ErrInvalidArgument(gitalyerrors.ErrEmptyRepository)
diff --git a/internal/gitaly/service/repository/repack_test.go b/internal/gitaly/service/repository/repack_test.go
index 7e73290a6..d7efb78dc 100644
--- a/internal/gitaly/service/repository/repack_test.go
+++ b/internal/gitaly/service/repository/repack_test.go
@@ -300,25 +300,3 @@ func TestRepackFullDeltaIslands(t *testing.T) {
return err
})
}
-
-func TestLog2Threads(t *testing.T) {
- t.Parallel()
- for _, tt := range []struct {
- cpus int
- threads string
- }{
- {1, "1"},
- {2, "1"},
- {3, "1"},
- {4, "2"},
- {8, "3"},
- {9, "3"},
- {13, "3"},
- {16, "4"},
- {27, "4"},
- {32, "5"},
- } {
- actualThreads := log2Threads(tt.cpus)
- require.Equal(t, tt.threads, actualThreads.Value)
- }
-}