summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancisco Javier López <fjlopez@gitlab.com>2018-07-27 13:01:40 -0400
committerFrancisco Javier López <fjlopez@gitlab.com>2018-07-27 13:01:40 -0400
commitaf46f52370fc9ad449611cff0277cd7706a05bbb (patch)
tree76b1d48850823e5264f5ae8d961423d0452a6630
parent334ee10727540c8e16d47075781564fd21e8a9cb (diff)
downloadgitlab-ce-fj-37736-improve-performance-post-receive-project-cache-worker.tar.gz
Making call to ProjectCacheWorker optional in PostReceivefj-37736-improve-performance-post-receive-project-cache-worker
-rw-r--r--app/services/git_push_service.rb10
-rw-r--r--app/services/git_tag_push_service.rb6
-rw-r--r--app/workers/post_receive.rb6
3 files changed, 14 insertions, 8 deletions
diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb
index 29c8ce5fea3..05073e9976f 100644
--- a/app/services/git_push_service.rb
+++ b/app/services/git_push_service.rb
@@ -20,7 +20,7 @@ class GitPushService < BaseService
# 5. Executes the project's services
# 6. Checks if the project's main language has changed
#
- def execute
+ def execute(update_statistics: true)
@project.repository.after_create if @project.empty_repo?
@project.repository.after_push_commit(branch_name)
@@ -58,7 +58,7 @@ class GitPushService < BaseService
perform_housekeeping
update_remote_mirrors
- update_caches
+ update_caches(update_statistics)
update_signatures
end
@@ -67,7 +67,7 @@ class GitPushService < BaseService
@project.repository.copy_gitattributes(params[:ref])
end
- def update_caches
+ def update_caches(update_statistics)
if default_branch?
if push_to_new_branch?
# If this is the initial push into the default branch, the file type caches
@@ -88,7 +88,9 @@ class GitPushService < BaseService
types = []
end
- ProjectCacheWorker.perform_async(@project.id, types, [:commit_count, :repository_size])
+ if update_statistics || types.any?
+ ProjectCacheWorker.perform_async(@project.id, types, [:commit_count, :repository_size])
+ end
end
def update_signatures
diff --git a/app/services/git_tag_push_service.rb b/app/services/git_tag_push_service.rb
index 3ff2d1d107d..60c8d91e7a1 100644
--- a/app/services/git_tag_push_service.rb
+++ b/app/services/git_tag_push_service.rb
@@ -3,7 +3,7 @@
class GitTagPushService < BaseService
attr_accessor :push_data
- def execute
+ def execute(update_statistics: true)
project.repository.after_create if project.empty_repo?
project.repository.before_push_tag
@@ -16,7 +16,9 @@ class GitTagPushService < BaseService
project.execute_hooks(@push_data.dup, :tag_push_hooks)
project.execute_services(@push_data.dup, :tag_push_hooks)
- ProjectCacheWorker.perform_async(project.id, [], [:commit_count, :repository_size])
+ if update_statistics
+ ProjectCacheWorker.perform_async(project.id, [], [:commit_count, :repository_size])
+ end
true
end
diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb
index 09a594cdb4e..3fd07a84fae 100644
--- a/app/workers/post_receive.rb
+++ b/app/workers/post_receive.rb
@@ -39,15 +39,17 @@ class PostReceive
end
if Gitlab::Git.tag_ref?(ref)
- GitTagPushService.new(post_received.project, @user, oldrev: oldrev, newrev: newrev, ref: ref).execute
+ GitTagPushService.new(post_received.project, @user, oldrev: oldrev, newrev: newrev, ref: ref).execute(update_statistics: false)
elsif Gitlab::Git.branch_ref?(ref)
- GitPushService.new(post_received.project, @user, oldrev: oldrev, newrev: newrev, ref: ref).execute
+ GitPushService.new(post_received.project, @user, oldrev: oldrev, newrev: newrev, ref: ref).execute(update_statistics: false)
end
changes << Gitlab::DataBuilder::Repository.single_change(oldrev, newrev, ref)
refs << ref
end
+ ProjectCacheWorker.perform_async(project.id, [], [:commit_count, :repository_size])
+
after_project_changes_hooks(post_received, @user, refs.to_a, changes)
end