diff options
author | John Cai <jcai@gitlab.com> | 2019-05-06 16:57:44 -0700 |
---|---|---|
committer | John Cai <jcai@gitlab.com> | 2019-05-14 12:13:19 -0500 |
commit | f86797b5a91791875ccd1a02806d4cab236c1ac6 (patch) | |
tree | e48b1e9bcf1e068baf84d4780e65c25b5c9a9110 /app | |
parent | e1aa7f5074aab8190d16a6f25121d33b99a07238 (diff) | |
download | gitlab-ce-f86797b5a91791875ccd1a02806d4cab236c1ac6.tar.gz |
Omit max-count for diverging_commit_counts behind feature flagjc-omit-count-diverging-commits-max
We want to optimize the query for the CountDivergingCommits rpc by
removing the --max-count argument now that we have commit graphs
enabled for all repositories during housekeeping. However, we want to
test this first behind a feature flag.
Diffstat (limited to 'app')
-rw-r--r-- | app/models/repository.rb | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index be17b54ff12..5a003f25944 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -283,14 +283,19 @@ class Repository end def diverging_commit_counts(branch) + return diverging_commit_counts_without_max(branch) if Feature.enabled?('gitaly_count_diverging_commits_no_max') + + ## TODO: deprecate the below code after 12.0 @root_ref_hash ||= raw_repository.commit(root_ref).id cache.fetch(:"diverging_commit_counts_#{branch.name}") do # Rugged seems to throw a `ReferenceError` when given branch_names rather # than SHA-1 hashes + branch_sha = branch.dereferenced_target.sha + number_commits_behind, number_commits_ahead = raw_repository.diverging_commit_count( @root_ref_hash, - branch.dereferenced_target.sha, + branch_sha, max_count: MAX_DIVERGING_COUNT) if number_commits_behind + number_commits_ahead >= MAX_DIVERGING_COUNT @@ -301,6 +306,22 @@ class Repository end end + def diverging_commit_counts_without_max(branch) + @root_ref_hash ||= raw_repository.commit(root_ref).id + cache.fetch(:"diverging_commit_counts_without_max_#{branch.name}") do + # Rugged seems to throw a `ReferenceError` when given branch_names rather + # than SHA-1 hashes + branch_sha = branch.dereferenced_target.sha + + number_commits_behind, number_commits_ahead = + raw_repository.diverging_commit_count( + @root_ref_hash, + branch_sha) + + { behind: number_commits_behind, ahead: number_commits_ahead } + end + end + def archive_metadata(ref, storage_path, format = "tar.gz", append_sha:, path: nil) raw_repository.archive_metadata( ref, |