diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-09-01 12:50:14 +0200 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2017-09-08 00:46:16 +0200 |
commit | 83355336dd405a3af9914a6ae6d397a631847e49 (patch) | |
tree | 5d29e49adab65e9dd9b130344d418d5b4c936c9b /spec/features/dashboard/projects_spec.rb | |
parent | 3955dcb4cc4cf305282412988751155771bbc036 (diff) | |
download | gitlab-ce-83355336dd405a3af9914a6ae6d397a631847e49.tar.gz |
Rework how recent push events are retrieveduser-recent-push
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
Diffstat (limited to 'spec/features/dashboard/projects_spec.rb')
-rw-r--r-- | spec/features/dashboard/projects_spec.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/spec/features/dashboard/projects_spec.rb b/spec/features/dashboard/projects_spec.rb index 0613c158c54..9a7b8e3ba6b 100644 --- a/spec/features/dashboard/projects_spec.rb +++ b/spec/features/dashboard/projects_spec.rb @@ -83,12 +83,14 @@ feature 'Dashboard Projects' do end end - context 'last push widget' do + context 'last push widget', :use_clean_rails_memory_store_caching do before do event = create(:push_event, project: project, author: user) create(:push_event_payload, event: event, ref: 'feature', action: :created) + Users::LastPushEventService.new(user).cache_last_push_event(event) + visit dashboard_projects_path end |