Skip to content

Resolve "Projects::MergeRequestsController#index makes 100 redis calls"

What does this MR do?

Related to: #230285 (closed)

When we load the list of merge requests, we are doing a redis call to see if every branch exists. That means, we may do a total of 40 redis calls (20 merge requests per page * 2 branches) to check this.

In reality, we do an average of around 30 total for this page request, shown here: https://log.gprd.gitlab.net/goto/f4b0df2f7916e0611db954221736181b

As identified in the issue by @garyh, #230285 (comment 413333500), we call source_branch_exists and target_branch_exists multiple times. These are currently being cached in lib/gitlab/repository_cache_adapter.rb.

This class will check if the branch_names is already memoized before calling the redis cache. The idea behind this merge request is that we can load the branch_names into memory before this page, so we don't need to look into redis for each branch.

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Marc Shaw

Merge request reports