You need to sign in or sign up before continuing.
Take the advantage of --left-right in Gitaly for diverging_commit_counts
For now Gitaly doesn't support --left-right
for counting commits. When it does, take the advantage of that and update Gitlab::Git::Repository#count_commits_by_gitaly
to make exactly one call instead of two calls.
Current code:
def count_commits_by_gitaly(options)
if options[:left_right]
from = options[:from]
to = options[:to]
right_count = gitaly_commit_client
.commit_count("#{from}..#{to}", options)
left_count = gitaly_commit_client
.commit_count("#{to}..#{from}", options)
[left_count, right_count]
else
gitaly_commit_client.commit_count(options[:ref], options)
end
end
Ideally it should look like this:
def count_commits_by_gitaly(options)
ref = options[:ref] || "#{options[:from]}..#{options[:to]}"
gitaly_commit_client.commit_count(ref, options)
end
Original title
Eliminate n+1 calls on diverging_commit_counts for BranchesController#index
Original description
Background
This was originally filed at https://gitlab.com/gitlab-org/gitlab-ce/issues/40622, and we closed that via https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/15963, but we didn't resolve the original issue. However, we did:
- Use
--max-count=1000
for Gitaly and shelling out, so we would show999+
instead of say,123456
when it's far behind or ahead - Also use
--left-right
for shelling out, which could roughly make the page loads 100% faster (half time)
What we still need to do
- We still have n+1 calls
- Gitaly didn't support
--left-right
yet, which could potentially make this page load 100% faster
Edited by Lin Jen-Shin