Commit 1ab72b83 authored by Stan Hu's avatar Stan Hu

Fix Gitaly duration timings for other CommitService RPCs

For many Gitaly RPCs, previously the `gitaly_duration_s` log timings
only accounted for the initial request/response time. We now measure the
total time it takes to consume the streaming response for the following
RPCs:

1. CommitDelta
2. FilterShasWithSignatures
3. CommitDiff

Part of https://gitlab.com/gitlab-org/gitlab/-/issues/30334
parent a8b86015
---
title: Fix Gitaly duration timings for other CommitService RPCs
merge_request: 34933
author:
type: other
...@@ -72,10 +72,10 @@ module Gitlab ...@@ -72,10 +72,10 @@ module Gitlab
def commit_deltas(commit) def commit_deltas(commit)
request = Gitaly::CommitDeltaRequest.new(diff_from_parent_request_params(commit)) request = Gitaly::CommitDeltaRequest.new(diff_from_parent_request_params(commit))
response = GitalyClient.call(@repository.storage, :diff_service, :commit_delta, request, timeout: GitalyClient.fast_timeout) GitalyClient.streaming_call(@repository.storage, :diff_service, :commit_delta, request, timeout: GitalyClient.fast_timeout) do |response|
response.flat_map { |msg| msg.deltas } response.flat_map { |msg| msg.deltas }
end end
end
def tree_entry(ref, path, limit = nil) def tree_entry(ref, path, limit = nil)
if Pathname.new(path).cleanpath.to_s.start_with?('../') if Pathname.new(path).cleanpath.to_s.start_with?('../')
...@@ -348,12 +348,12 @@ module Gitlab ...@@ -348,12 +348,12 @@ module Gitlab
end end
end end
response = GitalyClient.call(@repository.storage, :commit_service, :filter_shas_with_signatures, enum, timeout: GitalyClient.fast_timeout) GitalyClient.streaming_call(@repository.storage, :commit_service, :filter_shas_with_signatures, enum, timeout: GitalyClient.fast_timeout) do |response|
response.flat_map do |msg| response.flat_map do |msg|
msg.shas.map { |sha| EncodingHelper.encode!(sha) } msg.shas.map { |sha| EncodingHelper.encode!(sha) }
end end
end end
end
def get_commit_signatures(commit_ids) def get_commit_signatures(commit_ids)
request = Gitaly::GetCommitSignaturesRequest.new(repository: @gitaly_repo, commit_ids: commit_ids) request = Gitaly::GetCommitSignaturesRequest.new(repository: @gitaly_repo, commit_ids: commit_ids)
...@@ -399,9 +399,10 @@ module Gitlab ...@@ -399,9 +399,10 @@ module Gitlab
request_params.merge!(Gitlab::Git::DiffCollection.limits(options).to_h) request_params.merge!(Gitlab::Git::DiffCollection.limits(options).to_h)
request = Gitaly::CommitDiffRequest.new(request_params) request = Gitaly::CommitDiffRequest.new(request_params)
response = GitalyClient.call(@repository.storage, :diff_service, :commit_diff, request, timeout: GitalyClient.medium_timeout) GitalyClient.streaming_call(@repository.storage, :diff_service, :commit_diff, request, timeout: GitalyClient.medium_timeout) do |response|
GitalyClient::DiffStitcher.new(response) GitalyClient::DiffStitcher.new(response)
end end
end
def diff_from_parent_request_params(commit, options = {}) def diff_from_parent_request_params(commit, options = {})
parent_id = commit.parent_ids.first || Gitlab::Git::EMPTY_TREE_ID parent_id = commit.parent_ids.first || Gitlab::Git::EMPTY_TREE_ID
......
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