Load merge request diffs incrementally
Problem to solve
When I decide to open a merge request to perform a code review or respond to feedback, I want to maintain my flow and focus in this task without delays that will break my flow like a slow page load, or needing to reload the page because of a time out, so that I feel like I am in control of what I work on an when and that I am able to be be a good team member that responds in a timely fashion.
But, when I open a non-trivial merge request the page is slow to load while I wait for all the discussions and diffs to load before I can do anything. This interrupts my flow, and I often leave the tab open while I do something else, and then get distracted and forget to go back to the merge request I had opened.
This is caused, in part by the entire diff being loaded all at once.
Further details
This was a finding of the discovery sprint https://gitlab.com/gitlab-org/gitlab-ce/issues/62536
Proposal
- Create a new diffs API that is paginated, allowing the diffs to be loaded progressively in alphabetical order (the same order as the file tree)
- Use the new paginated API to progressively render the diff. As soon as one page is returned, request the next page.
UX involvement will needed to decide if we create empty placeholders for each file, and then fill in the diff into those placeholders, or if we add items as they arrive to the bottom of the list.
We will need to consider a direct link to a specific file in Changes tab, that we cannot jump to that location until the page with that file has been loaded.
Measuring success
TTFB should be less than 200ms for the diff endpoint when the cache is primed.
This change is being made in coordination with &1816 (closed) which will improve performance of the merge request interface, and provide the foundation for reducing the frequency with which diff limits are hit https://gitlab.com/gitlab-org/gitlab-ce/issues/66638.