Commit ea81c276 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Submit a single batch blob RPC to Gitaly per HTTP request when viewing diffs

parent cb5cc14d
---
title: Submit a single batch blob RPC to Gitaly per HTTP request when viewing diffs
merge_request:
author:
type: performance
......@@ -13,7 +13,16 @@ module Gitlab
end
def diff_files
super.tap { |_| store_highlight_cache }
# Make sure to _not_ send any method call to Gitlab::Diff::File
# _before_ all of them were collected (`super`). Premature method calls will
# trigger N+1 RPCs to Gitaly through BatchLoader records (Blob.lazy).
#
diff_files = super
diff_files.each { |diff_file| cache_highlight!(diff_file) if cacheable?(diff_file) }
store_highlight_cache
diff_files
end
def real_size
......@@ -22,13 +31,6 @@ module Gitlab
private
# Extracted method to highlight in the same iteration to the diff_collection.
def decorate_diff!(diff)
diff_file = super
cache_highlight!(diff_file) if cacheable?(diff_file)
diff_file
end
def highlight_diff_file_from_cache!(diff_file, cache_diff_lines)
diff_file.highlighted_diff_lines = cache_diff_lines.map do |line|
Gitlab::Diff::Line.init_from_hash(line)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment