Improve performance of jobs controller show
What does this MR do?
Improve performance of
TL;DR; No N+1 Gitaly calls when there are deployments in a pipeline, no unnecessary Gitaly call whatsoever. A request to
Projects::JobsController#show.json should result in 0 additional Gitaly calls.
- Calls to
Ci::Pipeline#latest?usually require a Gitaly request, but we do not need this information on a build details page, thus this merge request moves serialization of this flag to
- Before this change a visit to a build details page resulted in making a request to serialize entire pipeline again (using
PipelineDetailsEntity) what was really expensive. We did that only to get a list of stages, and out frontend code actually only needed names of the stages. We now serialize this information once and send it back in a payload from
JobsController#show.json. This avoids unnecessary serialization of entire pipeline and saves us another Gitaly request.
- Before this change, whenever there was a deployment somewhere in the pipeline, N+1 Gitaly calls were involved in checking an access to a possible protected ref. This was a legitimate Gitaly call, because a latest deployment
deployablecan be present in a completely different pipeline, on a completely different ref, so caching is difficult. It appears however that we do not display this information anywhere on a build details page, thus we don't really need to serialize that, and this merge request adds
Timings generated using gitlab-structlog from customer's logs:
Closes #60708 (closed)