Merge request not loading due to Gitaly calls and highlighting
@dimitrieh noticed that https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/14609 did not load. It looks like it times out after 60 s. We added it to the profile list in gitlab-com/gitlab-profiler!38 (merged). The profiler results:
- ruby-prof: http://profiler.gitlap.com/20180306/efd3a74b-749b-4272-be07-daa3c43e9bf5.html.gz
- SQL: http://profiler.gitlap.com/20180306/efd3a74b-749b-4272-be07-daa3c43e9bf5.txt.gz
Under the profiler, you can see the problem really is not really due to SQL, although the 1 SQL load times could probably be optimized:
I, [2018-03-06T23:52:58.784265 #23621] INFO -- : Completed 200 OK in 193620ms (Views: 179060.6ms | ActiveRecord: 841.4ms | Elasticsearch: 0.0ms)
At least 20% of the load times can be attributed to Gitaly. For example, one issue here is that I see that Repository#empty?
is not being memoized:
Another issue is that we call find_merge_base
repeatedly:
However, 25% of the load time is due to highlighting diffs:
Edited by Stan Hu