[go: up one dir, main page]

Skip to content

Improve performance of finding file by file_hash in diff_by_file_hash

Background

Finding a file by file_hash param in diff_by_file_hash action can take some time.

Proposal

Inspired by @slashmanov's suggestion in #387246 (comment 1781554417), we can utilize associated MergeRequestDiffFile records to find file by file_hash in Projects::MergeRequests::DiffsController#diff_by_file_hash.

We do have to consider other edge cases wherein MergeRequestDiff has no associated MergeRequestDiffFile as we clean them up after merging for non-latest diffs.

Basic benchmark shows massive improvement for large MRs: #387246 (comment 1782384779).

Edited by Patrick Bajao