Use incremental cache updates in PostReceive
What does this MR do and why?
Contributes to #553426 (closed)
Problem
Recreation of branch/tags cache is an expensive operation for large repositories. It leads to poor performance of PostReceive worker.
Solution
Update only changed records in the cache instead of dropping and recreating the whole cache.
References
Sidekiq high-urgency-cpu-bound job PostReceive ... (#553426 - closed)
How to set up and validate locally
- Enable feature flag
Feature.enable(:incremental_cache_for_refs)
- Clone a project from GDK to your local machine
- Open a Rails console and execute this code snippet to get status of branch names
Project.find(project_id).repository.branch_names
- Locally create a new branch and push it to GDK
- Re-run the code snippet to confirm that the list of names was updated
Example:
# in Rails console
Project.last.repository.branch_names
=> ["main", "new-branch1", "new-branch2", "test", "test2"]
# in Shell Terminal (delete branches)
git push local new-branch1 new-branch2 test -d
# in Rails console
Project.last.repository.branch_names
=> ["main", "test2"]
# in Shell Terminal (add branches)
git push local new-branch1 new-branch2
# in Rails console
Project.last.repository.branch_names
=> ["main", "new-branch1", "new-branch2", "test2"]
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #553426 (closed)
Edited by Vasilii Iakliushin