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-01-16 18:30:27 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2023-01-18 13:22:09 +0300
commitd15e9278eed3c53f9ebfc6f4d3a3e4c4b0975876 (patch)
treef58eb2313c1ef61550c652b7b7afa4adad6bfd49
parent72b8321f0b852e9e043be6d9743ce61f4ed57305 (diff)
git/stats: Report on multi-pack-indices
We'll soon start writing multi-pack-indices in our repository maintenance. Start exposing information about multi-pack-indices so that we can monitor the progress of that change. Please refer to the gitformat-pack(5) man page for further details on these data structures.
-rw-r--r--internal/git/stats/repository_info.go8
-rw-r--r--internal/git/stats/repository_info_test.go38
2 files changed, 42 insertions, 4 deletions
diff --git a/internal/git/stats/repository_info.go b/internal/git/stats/repository_info.go
index d14cbc3a2..363b267bd 100644
--- a/internal/git/stats/repository_info.go
+++ b/internal/git/stats/repository_info.go
@@ -240,6 +240,10 @@ type PackfilesInfo struct {
GarbageSize uint64 `json:"garbage_size"`
// HasBitmap indicates whether the packfiles have a bitmap.
HasBitmap bool `json:"has_bitmap"`
+ // HasMultiPackIndex indicates whether there is a multi-pack-index.
+ HasMultiPackIndex bool `json:"has_multi_pack_index"`
+ // HasMultiPackIndexBitmap indicates whether the multi-pack-index has a bitmap.
+ HasMultiPackIndexBitmap bool `json:"has_multi_pack_index_bitmap"`
}
// PackfilesInfoForRepository derives various information about packfiles for the given repository.
@@ -286,6 +290,10 @@ func PackfilesInfoForRepository(repo *localrepo.Repo) (PackfilesInfo, error) {
case strings.HasSuffix(entryName, ".bitmap"):
info.HasBitmap = true
}
+ case entryName == "multi-pack-index":
+ info.HasMultiPackIndex = true
+ case strings.HasPrefix(entryName, "multi-pack-index-") && strings.HasSuffix(entryName, ".bitmap"):
+ info.HasMultiPackIndexBitmap = true
default:
info.GarbageCount++
if entryInfo.Size() > 0 {
diff --git a/internal/git/stats/repository_info_test.go b/internal/git/stats/repository_info_test.go
index 8fa25c6fe..1c2be2ead 100644
--- a/internal/git/stats/repository_info_test.go
+++ b/internal/git/stats/repository_info_test.go
@@ -737,6 +737,32 @@ func TestPackfileInfoForRepository(t *testing.T) {
})
})
+ t.Run("multi-pack-index", func(t *testing.T) {
+ repo, repoPath := createRepo(t)
+
+ packfileDir := filepath.Join(repoPath, "objects", "pack")
+ require.NoError(t, os.MkdirAll(packfileDir, 0o755))
+ require.NoError(t, os.WriteFile(filepath.Join(packfileDir, "multi-pack-index"), nil, 0o644))
+
+ requirePackfilesInfo(t, repo, PackfilesInfo{
+ HasMultiPackIndex: true,
+ })
+ })
+
+ t.Run("multi-pack-index with bitmap", func(t *testing.T) {
+ repo, repoPath := createRepo(t)
+
+ packfileDir := filepath.Join(repoPath, "objects", "pack")
+ require.NoError(t, os.MkdirAll(packfileDir, 0o755))
+ require.NoError(t, os.WriteFile(filepath.Join(packfileDir, "multi-pack-index"), nil, 0o644))
+ require.NoError(t, os.WriteFile(filepath.Join(packfileDir, "multi-pack-index-c0363841cc7e5783a996c72f0a4a7ae4440aaa40.bitmap"), nil, 0o644))
+
+ requirePackfilesInfo(t, repo, PackfilesInfo{
+ HasMultiPackIndex: true,
+ HasMultiPackIndexBitmap: true,
+ })
+ })
+
t.Run("multiple packfiles with other data structures", func(t *testing.T) {
repo, repoPath := createRepo(t)
@@ -750,15 +776,19 @@ func TestPackfileInfoForRepository(t *testing.T) {
"pack-foo.pack",
"pack-foo.idx",
"garbage",
+ "multi-pack-index",
+ "multi-pack-index-c0363841cc7e5783a996c72f0a4a7ae4440aaa40.bitmap",
} {
require.NoError(t, os.WriteFile(filepath.Join(packfileDir, file), []byte("1"), 0o644))
}
requirePackfilesInfo(t, repo, PackfilesInfo{
- Count: 2,
- Size: 2,
- GarbageCount: 1,
- GarbageSize: 1,
+ Count: 2,
+ Size: 2,
+ GarbageCount: 1,
+ GarbageSize: 1,
+ HasMultiPackIndex: true,
+ HasMultiPackIndexBitmap: true,
})
})
}