Slow branch list on repositories with long branches
- Backend weight: 3
- Frontend weight: 3
Summary
On a repository with long branches (e.g. long-lived, active release branches) rendering the branch list (i.e. navigating to Repository -> Branches) takes a long time.
Example Project
https://gitlab.com/steffeng/long-branches
Details
The example repo linked above mimics the structure of one our internal repositories with about 500.000 commits on master and 50 "long" branches branched off of master
each with about 5000 commits. After pushing to the repo, rendering the branch overview takes 5-10 seconds and rendering all active branches takes 30-60 seconds. Subsequent page loads are faster (in the order of 3-5 seconds), so I'm guessing some caching is in place. Pushing new content to the repo seems to invalidate the cache and bring rendering times up to 5-10 respectively 30-60 seconds on the next page load - occasionally resulting in a 502 response.
With a warm cache I would not expect rendering to take several seconds, so any improvements that could be done on that would be very welcome.
With a cold cache, I suspect that a major part of the time is spent counting commits ahead/behind master
for each branch. I'm not entirely familiar with how GitLab/Gitaly computes those numbers, but in a local repo I would do
$ time git rev-list --left-right --count master...branch15
352946 5006
real 0m3.080s
user 0m2.898s
sys 0m0.166s
and that's 3 seconds just for a single branch. I see no immediate way to make git compute these number for several branches at once, and even if that was possible I would suspect it to still be quite slow, so computing and rendering the counts async might be an option.