Skip to content

Make a single request to Gitaly through `Gitlab::Git::Blob.batch` when viewing diffs

Current investigations on gitaly#1061 (closed) and https://gitlab.com/gitlab-org/gitlab-ce/issues/38408 shows that we're currently submitting about a request per merge_request_diff_file of a Merge Request to Gitaly to present the default diffs tab state (Changes).

Interestingly, this is submitted by a batch method which is not actually batching the requests properly (or was not intentionally implemented to do it) https://gitlab.com/gitlab-org/gitlab-ce/issues/38408#note_61705522. @jacobvosmaer-gitlab collected logs of RPC calls that clearly shows the issue (that's one request per line):

https://gitlab.com/gitlab-org/gitlab-ce/snippets/1702305

It's currently impacting Gitaly availability and the performance of DiffsController#show


Proposal

I think the most reasonable solution should be modifying the existing Blob.lazy method (or extract it) in order to submit a single RPC call (GetBlobs) per merge_request_id / merge_request_diff_id (?).

cc @DouweM @jacobvosmaer-gitlab @smcgivern

Edited by Oswaldo Ferreira