diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-07-08 12:50:10 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-07-15 16:15:09 +0300 |
commit | 8e372baf6221ba7e5dfef949122e52608e0b0f37 (patch) | |
tree | f70276123e98ad6e486d237157e60d81ebbd42fd | |
parent | b995e4ec151539d376e4da51bc1fa6c528c37682 (diff) |
housekeeping: Rewrite commit-graphs at a later point
Move writing of commit-graphs to happen after pruning of objects. This
is done so that we can start to use the information whether we pruned
any objects or not to decide whether to rewrite the commit-graph chain.
By moving the logic after packing refs we also have the benefit that we
have less loose refs to count in our heuristics.
-rw-r--r-- | internal/git/housekeeping/optimize_repository.go | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/internal/git/housekeeping/optimize_repository.go b/internal/git/housekeeping/optimize_repository.go index 2ee404c46..566583951 100644 --- a/internal/git/housekeeping/optimize_repository.go +++ b/internal/git/housekeeping/optimize_repository.go @@ -87,20 +87,6 @@ func optimizeRepository(ctx context.Context, m *RepositoryManager, repo *localre } timer.ObserveDuration() - timer = prometheus.NewTimer(m.tasksLatency.WithLabelValues("commit-graph")) - if didWriteCommitGraph, writeCommitGraphCfg, err := writeCommitGraphIfNeeded(ctx, repo, didRepack); err != nil { - optimizations["written_commit_graph_full"] = "failure" - optimizations["written_commit_graph_incremental"] = "failure" - return fmt.Errorf("could not write commit-graph: %w", err) - } else if didWriteCommitGraph { - if writeCommitGraphCfg.ReplaceChain { - optimizations["written_commit_graph_full"] = "success" - } else { - optimizations["written_commit_graph_incremental"] = "success" - } - } - timer.ObserveDuration() - timer = prometheus.NewTimer(m.tasksLatency.WithLabelValues("prune")) didPrune, err := pruneIfNeeded(ctx, repo) if err != nil { @@ -119,8 +105,22 @@ func optimizeRepository(ctx context.Context, m *RepositoryManager, repo *localre } else if didPackRefs { optimizations["packed_refs"] = "success" } + timer.ObserveDuration() + timer = prometheus.NewTimer(m.tasksLatency.WithLabelValues("commit-graph")) + if didWriteCommitGraph, writeCommitGraphCfg, err := writeCommitGraphIfNeeded(ctx, repo, didRepack); err != nil { + optimizations["written_commit_graph_full"] = "failure" + optimizations["written_commit_graph_incremental"] = "failure" + return fmt.Errorf("could not write commit-graph: %w", err) + } else if didWriteCommitGraph { + if writeCommitGraphCfg.ReplaceChain { + optimizations["written_commit_graph_full"] = "success" + } else { + optimizations["written_commit_graph_incremental"] = "success" + } + } timer.ObserveDuration() + totalStatus = "success" return nil |