Optimize code_review_id to use blob IDs from Gitaly diff response

What does this MR do and why?

Why

code_review_id previously called blob&.id which triggered Gitaly GetBlobs RPC fetching up to 512KB of content per file just to obtain the OID. For large diffs this causes GRPC::DeadlineExceeded and ActiveRecord::QueryCanceled on the diff_files_metadata endpoint.

What

Store from_id/to_id from Gitaly's CommitDiffResponse on Gitlab::Git::Diff. Use these in code_review_id via a new blob_id helper, avoiding any additional Gitaly calls for streamed diffs. Falls back to blob&.id for persisted diffs where these IDs are not available.

Behind feature flag diff_blob_metadata_only_for_code_review_id.

References

The approach was proposed in !232121 (comment 3267252294) in favour of !232121 (closed)

Sentry errors

How to set up and validate locally

Specs should pass.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Gavin Hinfey

Merge request reports

Loading