mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-15 07:36:41 +10:00
Merge branch 'project-cache-worker-without-diverging' into 'master'
Removed diverging commit count calculation from Repository#build_cache Using a repository with 1000 branches the old `Repository#build_cache` method would take around 180 seconds to complete. Without calculating the diverging commit counts this method "only" takes around 60 seconds. See commit 28cc2413eb5ddf920ce0b5eed803121f8b884754 for more details. This fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/14058 cc @rspeicher See merge request !3274
This commit is contained in:
@@ -227,12 +227,6 @@ class Repository
|
||||
send(key)
|
||||
end
|
||||
end
|
||||
|
||||
branches.each do |branch|
|
||||
unless cache.exist?(:"diverging_commit_counts_#{branch.name}")
|
||||
send(:diverging_commit_counts, branch)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def expire_tags_cache
|
||||
@@ -301,18 +295,6 @@ class Repository
|
||||
@tag_count = nil
|
||||
end
|
||||
|
||||
def rebuild_cache
|
||||
cache_keys.each do |key|
|
||||
cache.expire(key)
|
||||
send(key)
|
||||
end
|
||||
|
||||
branches.each do |branch|
|
||||
cache.expire(:"diverging_commit_counts_#{branch.name}")
|
||||
diverging_commit_counts(branch)
|
||||
end
|
||||
end
|
||||
|
||||
def lookup_cache
|
||||
@lookup_cache ||= {}
|
||||
end
|
||||
|
||||
@@ -780,4 +780,34 @@ describe Repository, models: true do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#build_cache' do
|
||||
let(:cache) { repository.send(:cache) }
|
||||
|
||||
it 'builds the caches if they do not already exist' do
|
||||
expect(cache).to receive(:exist?).
|
||||
exactly(repository.cache_keys.length).
|
||||
times.
|
||||
and_return(false)
|
||||
|
||||
repository.cache_keys.each do |key|
|
||||
expect(repository).to receive(key)
|
||||
end
|
||||
|
||||
repository.build_cache
|
||||
end
|
||||
|
||||
it 'does not build any caches that already exist' do
|
||||
expect(cache).to receive(:exist?).
|
||||
exactly(repository.cache_keys.length).
|
||||
times.
|
||||
and_return(true)
|
||||
|
||||
repository.cache_keys.each do |key|
|
||||
expect(repository).to_not receive(key)
|
||||
end
|
||||
|
||||
repository.build_cache
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user