This is probably due to the Markdown pipeline having to process a lot of notes and probably running quite a few queries in the process. I've assigned this to 8.7 since we're not really sure just yet what's causing this and if it indeed is the Markdown pipeline there's probably quite a bit we have to change to improve things.
Designs
Child items
...
Show closed items
Linked items
0
Link issues together to show that they're related or that one is blocking others.
Learn more.
Some know bottlenecks human_max_access, cross_reference_not_visible_to_user?
Notes themselves
Participants, and link_to_member because ends calling can_push_to_branch?. But I think we just need to check can_push_to_branch? if the state of the MR is opened?why does a user need a message saying Not allowed to merge when the MR is not opened?
And some specific place to improve for this page widget/show/merged and a direct call to can_be_reverted? the partial call that method too and the value is not cached, and their calculation is expensive. I'll review for other statuses of the MRs.
ensure_ref_fetched (FileSystem), define_show_bars all data that is loaded (gitlab-foss!5070 (merged)) and closes_issues that is only needed when the MR is still open so I avoid their call as much as possible
Conclusions
Most of the improvement I think can be addressed on the work from gitlab-foss#19273 (closed) and in gitlab-foss!4101 (merged) I'll work in specific parts of this page but probably we'll revisit this after some releases of code that improves general parts of the applications (new diff notes, rendering notes and so on)
@pacoguzman All diff notes created before 8.10.0 RC7 are LegacyDiffNote objects, with a super slow LegacyDiffNote#active?. Any diff notes created after that use DiffNote and its much faster DiffNote#active?. All diff notes on https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/2987 are LegacyDiffNotes, so the amount of time that page spends in active? is not representative of any MR going forward.
I've updated the issue description to set gitlab-foss!5293 (merged) as example of a merge_request with a huge number of notes. And I'll profile that MR page instead
19.21% truncated_diff_lines we highlight all the lines of the file even if the note is at the begging or at the end (we can have more than one note per diff_file by the way)
13% DiffNote#diff_file, getting the diffs from the repository and iterate to get the first one (as we passed paths will be only one if exists)
9% rendering the notes
10% DiffNote#active?and this is the new implementation. It seems noteable is not cached on the first note of each discussion so even when this '#active?' method is faster that before we need to cache it into the discussion. Because for merge_requests try to calculate the diff_refs and that needs to access to the repository even when the merge request has a merge request diff record