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
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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