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-27 14:55:57 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2023-01-27 15:45:33 +0300
commita30997dda7e0b9fbe5ecb2e56c5f857a162471c2 (patch)
treef5d0473a92f881db57b18a39d04b8dbafbedb8fa
parent3c5d792a702f14b020944aa55c5b6a5da9d6bf2a (diff)
git/stats: Surface information about reverse indices
Packfiles can have reverse indices that allow Git to easily map an object location to its name in order to speed up some operations. Report on the availability of this data structure as part of the `PackfileInfo`. Changelog: added
-rw-r--r--internal/git/housekeeping/optimize_repository.go1
-rw-r--r--internal/git/stats/repository_info.go4
-rw-r--r--internal/git/stats/repository_info_test.go17
3 files changed, 22 insertions, 0 deletions
diff --git a/internal/git/housekeeping/optimize_repository.go b/internal/git/housekeeping/optimize_repository.go
index 1238e74f7..c0a248241 100644
--- a/internal/git/housekeeping/optimize_repository.go
+++ b/internal/git/housekeeping/optimize_repository.go
@@ -91,6 +91,7 @@ func (m *RepositoryManager) reportRepositoryInfo(ctx context.Context, info stats
m.reportDataStructureCount("loose_objects_stale_count", info.LooseObjects.StaleCount)
m.reportDataStructureCount("commit_graph_chain", info.CommitGraph.CommitGraphChainLength)
m.reportDataStructureCount("packfiles", info.Packfiles.Count)
+ m.reportDataStructureCount("packfiles_reverse_indices", info.Packfiles.ReverseIndexCount)
m.reportDataStructureCount("loose_references", info.References.LooseReferencesCount)
m.reportDataStructureSize("loose_objects", info.LooseObjects.Size)
diff --git a/internal/git/stats/repository_info.go b/internal/git/stats/repository_info.go
index 7ce5f2106..ddf974e49 100644
--- a/internal/git/stats/repository_info.go
+++ b/internal/git/stats/repository_info.go
@@ -241,6 +241,8 @@ type PackfilesInfo struct {
Count uint64 `json:"count"`
// Size is the total size of all loose objects in bytes, including stale ones.
Size uint64 `json:"size"`
+ // ReverseIndexCount is the number of reverse indices.
+ ReverseIndexCount uint64 `json:"reverse_index_count"`
// GarbageCount is the number of garbage files.
GarbageCount uint64 `json:"garbage_count"`
// GarbageSize is the total size of all garbage files in bytes.
@@ -290,6 +292,8 @@ func PackfilesInfoForRepository(repo *localrepo.Repo) (PackfilesInfo, error) {
if entryInfo.Size() > 0 {
info.Size += uint64(entryInfo.Size())
}
+ case hasPrefixAndSuffix(entryName, "pack-", ".rev"):
+ info.ReverseIndexCount++
case hasPrefixAndSuffix(entryName, "pack-", ".bitmap"):
bitmap, err := BitmapInfoForPath(filepath.Join(packfilesPath, entryName))
if err != nil {
diff --git a/internal/git/stats/repository_info_test.go b/internal/git/stats/repository_info_test.go
index f10e1096a..f58d55c6c 100644
--- a/internal/git/stats/repository_info_test.go
+++ b/internal/git/stats/repository_info_test.go
@@ -745,6 +745,23 @@ func TestPackfileInfoForRepository(t *testing.T) {
},
},
{
+ desc: "reverse index",
+ seedRepository: func(t *testing.T, repoPath string) {
+ gittest.WriteCommit(t, cfg, repoPath, gittest.WithBranch("main"))
+ gittest.Exec(t, cfg, "-c", "pack.writeReverseIndex=true", "-C", repoPath, "repack", "-Ad")
+ },
+ expectedInfo: PackfilesInfo{
+ Count: 1,
+ Size: hashDependentSize(163, 189),
+ ReverseIndexCount: 1,
+ Bitmap: BitmapInfo{
+ Exists: true,
+ Version: 1,
+ HasHashCache: true,
+ },
+ },
+ },
+ {
desc: "multi-pack-index",
seedRepository: func(t *testing.T, repoPath string) {
packfileDir := filepath.Join(repoPath, "objects", "pack")