Load merge request diffs incrementally for the latest version (persisted diffs)
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.
This was a finding of the discovery sprint https://gitlab.com/gitlab-org/gitlab-ce/issues/62536
- 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. Load the first X files (e.g. 5) quickly then iterate on Y files batch (e.g. 20). The backend endpoint will be generic enough so the FE will be able to pass the amount of files and the limit, etc.
- File loading appears as today, with a spinner centered on the file area.
- For this iteration we won’t preload the linked file yet, as it’ll need further work so the backend knows which file the user is trying to load, and for the FE to load it, to then load the other files.
- Repository fetching scenarios (commit and different versions) will be handled by #32859
TTFB should be less than 200ms for the diff endpoint when the cache is primed.
This change is being made in coordination with &1816 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.
Links / references
- Make local project with possible MR scenarios
- Has comments
- Has discussion threads
- Has draft comments
- Has multiple changed files
- Has large number of changes