Skip to content

Commit cdea863

Browse files
author
Robert Speicher
committed
Merge branch 'sh-defer-reference-counter-load' into 'master'
Optimize gitlab-projects by deferring the loading of gitlab_reference_counter See merge request !149
2 parents 8c760ed + 18d7c1d commit cdea863

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/gitlab_projects.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
require_relative 'gitlab_config'
66
require_relative 'gitlab_logger'
77
require_relative 'gitlab_metrics'
8-
require_relative 'gitlab_reference_counter'
98

109
class GitlabProjects
1110
GLOBAL_HOOKS_DIRECTORY = File.join(ROOT_PATH, 'hooks')
@@ -408,7 +407,12 @@ def wait_for_pushes
408407
end
409408

410409
def gitlab_reference_counter
411-
@gitlab_reference_counter ||= GitlabReferenceCounter.new(full_path)
410+
@gitlab_reference_counter ||= begin
411+
# Defer loading because this pulls in gitlab_net, which takes 100-200 ms
412+
# to load
413+
require_relative 'gitlab_reference_counter'
414+
GitlabReferenceCounter.new(full_path)
415+
end
412416
end
413417

414418
def rsync(src, dest, rsync_path = 'rsync')

0 commit comments

Comments
 (0)