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>2023-04-28 09:53:07 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2023-04-28 10:08:28 +0300
commit51dd9c0effa3a370f855a3b8d4060d456defa1b0 (patch)
treedc30388212559b10cd7317d8b9c876949f455820
parentd0eb94f3ff8fe6ce7d286d8fa45f60839faf4c76 (diff)
protoregistry: Benchmark retrieving repos from Protobuf messages
We're about to change the implementation of how we find the target and additional repository in Protobuf messages. Add a benchmark so that we can verify whether the new implementation is in fact fast enough.
-rw-r--r--internal/praefect/protoregistry/method_info_test.go52
1 files changed, 52 insertions, 0 deletions
diff --git a/internal/praefect/protoregistry/method_info_test.go b/internal/praefect/protoregistry/method_info_test.go
index d77501ee1..b2b1a2dc5 100644
--- a/internal/praefect/protoregistry/method_info_test.go
+++ b/internal/praefect/protoregistry/method_info_test.go
@@ -233,3 +233,55 @@ func TestMethodInfoScope(t *testing.T) {
})
}
}
+
+func BenchmarkMethodInfo(b *testing.B) {
+ for _, bc := range []struct {
+ desc string
+ method string
+ request proto.Message
+ expectedErr error
+ }{
+ {
+ desc: "unset target repository",
+ method: "/gitaly.RepositoryService/OptimizeRepository",
+ request: &gitalypb.OptimizeRepositoryRequest{
+ Repository: nil,
+ },
+ expectedErr: ErrTargetRepoMissing,
+ },
+ {
+ desc: "target repository",
+ method: "/gitaly.RepositoryService/OptimizeRepository",
+ request: &gitalypb.OptimizeRepositoryRequest{
+ Repository: &gitalypb.Repository{
+ StorageName: "something",
+ RelativePath: "something",
+ },
+ },
+ },
+ {
+ desc: "target object pool",
+ method: "/gitaly.ObjectPoolService/FetchIntoObjectPool",
+ request: &gitalypb.FetchIntoObjectPoolRequest{
+ ObjectPool: &gitalypb.ObjectPool{
+ Repository: &gitalypb.Repository{
+ StorageName: "something",
+ RelativePath: "something",
+ },
+ },
+ },
+ },
+ } {
+ b.Run(bc.desc, func(b *testing.B) {
+ mi, err := GitalyProtoPreregistered.LookupMethod(bc.method)
+ require.NoError(b, err)
+
+ b.ResetTimer()
+
+ for i := 0; i < b.N; i++ {
+ _, err := mi.TargetRepo(bc.request)
+ require.Equal(b, bc.expectedErr, err)
+ }
+ })
+ }
+}