diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-06-21 08:53:28 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-06-21 08:53:28 +0300 |
commit | d1dd987d926674aaa73315a99fc2ffe32d227c20 (patch) | |
tree | 4c64ba81db8f0a10a24901df353ca5eb9d4841a5 | |
parent | d2870b204c6801317a6e4c4fba09968fa6fd283d (diff) |
blob: Speed up blob search via object type filters
Same as with the `ListLFSPointers()` RPC, the `ListBlobs()` RPC
enumerates blobs reachable via a set of revisions. Given that we have
the same problem here as described in the preceding commit (non-blobs
get printed by default, as well as all explicitly provided revisions),
let's optimize the code by using the new object type filters, too.
Changelog: performance
-rw-r--r-- | internal/gitaly/service/blob/blobs.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/internal/gitaly/service/blob/blobs.go b/internal/gitaly/service/blob/blobs.go index abe6926b5..ce6e1dca9 100644 --- a/internal/gitaly/service/blob/blobs.go +++ b/internal/gitaly/service/blob/blobs.go @@ -8,6 +8,7 @@ import ( "strings" "github.com/golang/protobuf/proto" + "gitlab.com/gitlab-org/gitaly/v14/internal/git" "gitlab.com/gitlab-org/gitaly/v14/internal/helper" "gitlab.com/gitlab-org/gitaly/v14/internal/helper/chunk" "gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb" @@ -52,7 +53,17 @@ func (s *server) ListBlobs(req *gitalypb.ListBlobsRequest, stream gitalypb.BlobS }, }) - revlistChan := revlist(ctx, repo, req.GetRevisions()) + gitVersion, err := git.CurrentVersion(ctx, s.gitCmdFactory) + if err != nil { + return helper.ErrInternalf("cannot determine Git version: %v", err) + } + + var revlistOptions []revlistOption + if gitVersion.SupportsObjectTypeFilter() { + revlistOptions = append(revlistOptions, withObjectTypeFilter(objectTypeBlob)) + } + + revlistChan := revlist(ctx, repo, req.GetRevisions(), revlistOptions...) catfileInfoChan := catfileInfo(ctx, catfileProcess, revlistChan) catfileInfoChan = catfileInfoFilter(ctx, catfileInfoChan, func(r catfileInfoResult) bool { return r.objectInfo.Type == "blob" |