83355336dd
Whenever you push to a branch GitLab will show a button to create a merge request (should one not exist already). The underlying code to display this data was quite inefficient. For example, it involved multiple slow queries just to figure out what the most recent push event was. This commit changes the way this data is retrieved so it's much faster. This is achieved by caching the ID of the last push event on every push, which is then retrieved when loading certain pages. Database queries are only executed if necessary and the cached data is removed automatically once a merge request has been created, or 2 hours after being stored. A trade-off of this approach is that we _only_ track the last event. Previously if you were to push to branch A and B then create a merge request for branch B we'd still show the widget for branch A. As of this commit this is no longer the case, instead we will only show the widget for the branch you pushed to most recently. Once a merge request exists the widget is no longer displayed. Alternative solutions are either too complex and/or too slow, hence the decision was made to settle for this trade-off. Performance Impact ------------------ In the best case scenario (= a user didn't push anything for more than 2 hours) we perform a single Redis GET per page. Should there be cached data we will run a single (and lightweight) SQL query to get the event data from the database. If a merge request already exists we will run an additional DEL to remove the cache key. The difference in response timings can vary a bit per project. On GitLab.com the 99th percentile of time spent in User#recent_push hovers between 100 milliseconds and 1 second, while the mean hovers around 50 milliseconds. With the changes in this MR the expected time spent in User#recent_push is expected to be reduced down to just a few milliseconds. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/35990 |
||
---|---|---|
.. | ||
auth | ||
boards | ||
chat_names | ||
ci | ||
discussions | ||
emails | ||
files | ||
groups | ||
issuable | ||
issues | ||
labels | ||
members | ||
merge_requests | ||
milestones | ||
notes | ||
projects | ||
protected_branches | ||
protected_tags | ||
quick_actions | ||
search | ||
tags | ||
test_hooks | ||
users | ||
wiki_pages | ||
access_token_validation_service_spec.rb | ||
after_branch_delete_service_spec.rb | ||
cohorts_service_spec.rb | ||
compare_service_spec.rb | ||
create_branch_service_spec.rb | ||
create_deployment_service_spec.rb | ||
create_release_service_spec.rb | ||
create_snippet_service_spec.rb | ||
delete_branch_service_spec.rb | ||
delete_merged_branches_service_spec.rb | ||
event_create_service_spec.rb | ||
git_push_service_spec.rb | ||
git_tag_push_service_spec.rb | ||
gravatar_service_spec.rb | ||
import_export_clean_up_service_spec.rb | ||
note_summary_spec.rb | ||
notification_service_spec.rb | ||
pages_service_spec.rb | ||
preview_markdown_service_spec.rb | ||
push_event_payload_service_spec.rb | ||
repair_ldap_blocked_user_service_spec.rb | ||
repository_archive_clean_up_service_spec.rb | ||
search_service_spec.rb | ||
spam_service_spec.rb | ||
submit_usage_ping_service_spec.rb | ||
system_hooks_service_spec.rb | ||
system_note_service_spec.rb | ||
todo_service_spec.rb | ||
update_release_service_spec.rb | ||
update_snippet_service_spec.rb | ||
upload_service_spec.rb | ||
user_project_access_changed_service_spec.rb | ||
web_hook_service_spec.rb |