Commit 4bc24dd7 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Merge branch 'sh-fix-gitaly-blob-service-durations' into 'master'

Fix Gitaly duration timings of BlobService RPCs

See merge request gitlab-org/gitlab!34906
parents 90bc9841 f1d0bff1
---
title: Fix Gitaly duration timings of BlobService RPCs
merge_request: 34906
author:
type: other
...@@ -15,28 +15,9 @@ module Gitlab ...@@ -15,28 +15,9 @@ module Gitlab
oid: oid, oid: oid,
limit: limit limit: limit
) )
response = GitalyClient.call(@gitaly_repo.storage_name, :blob_service, :get_blob, request, timeout: GitalyClient.fast_timeout) GitalyClient.streaming_call(@gitaly_repo.storage_name, :blob_service, :get_blob, request, timeout: GitalyClient.fast_timeout) do |response|
consume_blob_response(response)
data = []
blob = nil
response.each do |msg|
if blob.nil?
blob = msg
end
data << msg.data
end end
return if blob.oid.blank?
data = data.join
Gitlab::Git::Blob.new(
id: blob.oid,
size: blob.size,
data: data,
binary: Gitlab::Git::Blob.binary?(data)
)
end end
def batch_lfs_pointers(blob_ids) def batch_lfs_pointers(blob_ids)
...@@ -47,9 +28,9 @@ module Gitlab ...@@ -47,9 +28,9 @@ module Gitlab
blob_ids: blob_ids blob_ids: blob_ids
) )
response = GitalyClient.call(@gitaly_repo.storage_name, :blob_service, :get_lfs_pointers, request, timeout: GitalyClient.medium_timeout) GitalyClient.streaming_call(@gitaly_repo.storage_name, :blob_service, :get_lfs_pointers, request, timeout: GitalyClient.medium_timeout) do |response|
map_lfs_pointers(response)
map_lfs_pointers(response) end
end end
def get_blobs(revision_paths, limit = -1) def get_blobs(revision_paths, limit = -1)
...@@ -65,15 +46,15 @@ module Gitlab ...@@ -65,15 +46,15 @@ module Gitlab
limit: limit limit: limit
) )
response = GitalyClient.call( GitalyClient.streaming_call(
@gitaly_repo.storage_name, @gitaly_repo.storage_name,
:blob_service, :blob_service,
:get_blobs, :get_blobs,
request, request,
timeout: GitalyClient.fast_timeout timeout: GitalyClient.fast_timeout
) ) do |response|
GitalyClient::BlobsStitcher.new(response)
GitalyClient::BlobsStitcher.new(response) end
end end
def get_blob_types(revision_paths, limit = -1) def get_blob_types(revision_paths, limit = -1)
...@@ -89,15 +70,15 @@ module Gitlab ...@@ -89,15 +70,15 @@ module Gitlab
limit: limit limit: limit
) )
response = GitalyClient.call( GitalyClient.streaming_call(
@gitaly_repo.storage_name, @gitaly_repo.storage_name,
:blob_service, :blob_service,
:get_blobs, :get_blobs,
request, request,
timeout: GitalyClient.fast_timeout timeout: GitalyClient.fast_timeout
) ) do |response|
map_blob_types(response)
map_blob_types(response) end
end end
def get_new_lfs_pointers(revision, limit, not_in, dynamic_timeout = nil) def get_new_lfs_pointers(revision, limit, not_in, dynamic_timeout = nil)
...@@ -120,15 +101,15 @@ module Gitlab ...@@ -120,15 +101,15 @@ module Gitlab
GitalyClient.medium_timeout GitalyClient.medium_timeout
end end
response = GitalyClient.call( GitalyClient.streaming_call(
@gitaly_repo.storage_name, @gitaly_repo.storage_name,
:blob_service, :blob_service,
:get_new_lfs_pointers, :get_new_lfs_pointers,
request, request,
timeout: timeout timeout: timeout
) ) do |response|
map_lfs_pointers(response)
map_lfs_pointers(response) end
end end
def get_all_lfs_pointers def get_all_lfs_pointers
...@@ -136,13 +117,36 @@ module Gitlab ...@@ -136,13 +117,36 @@ module Gitlab
repository: @gitaly_repo repository: @gitaly_repo
) )
response = GitalyClient.call(@gitaly_repo.storage_name, :blob_service, :get_all_lfs_pointers, request, timeout: GitalyClient.medium_timeout) GitalyClient.streaming_call(@gitaly_repo.storage_name, :blob_service, :get_all_lfs_pointers, request, timeout: GitalyClient.medium_timeout) do |response|
map_lfs_pointers(response)
map_lfs_pointers(response) end
end end
private private
def consume_blob_response(response)
data = []
blob = nil
response.each do |msg|
if blob.nil?
blob = msg
end
data << msg.data
end
return if blob.oid.blank?
data = data.join
Gitlab::Git::Blob.new(
id: blob.oid,
size: blob.size,
data: data,
binary: Gitlab::Git::Blob.binary?(data)
)
end
def map_lfs_pointers(response) def map_lfs_pointers(response)
response.flat_map do |message| response.flat_map do |message|
message.lfs_pointers.map do |lfs_pointer| message.lfs_pointers.map do |lfs_pointer|
......
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