Commit cf0a1f60 authored by Matthias Kaeppler's avatar Matthias Kaeppler

Use Runtime.max_threads to size Redis caches

parent cc77644b
...@@ -22,11 +22,8 @@ module Gitlab ...@@ -22,11 +22,8 @@ module Gitlab
def pool_size def pool_size
# heuristic constant 5 should be a config setting somewhere -- related to CPU count? # heuristic constant 5 should be a config setting somewhere -- related to CPU count?
size = 5 size = 5
if Gitlab::Runtime.sidekiq? if Gitlab::Runtime.multi_threaded?
# the pool will be used in a multi-threaded context size += Gitlab::Runtime.max_threads
size += Sidekiq.options[:concurrency]
elsif Gitlab::Runtime.puma?
size += Puma.cli_config.options[:max_threads]
end end
size size
......
...@@ -116,9 +116,9 @@ RSpec.shared_examples "redis_shared_examples" do ...@@ -116,9 +116,9 @@ RSpec.shared_examples "redis_shared_examples" do
clear_pool clear_pool
end end
context 'when running not on sidekiq workers' do context 'when running on single-threaded runtime' do
before do before do
allow(Gitlab::Runtime).to receive(:sidekiq?).and_return(false) allow(Gitlab::Runtime).to receive(:multi_threaded?).and_return(false)
end end
it 'instantiates a connection pool with size 5' do it 'instantiates a connection pool with size 5' do
...@@ -128,10 +128,10 @@ RSpec.shared_examples "redis_shared_examples" do ...@@ -128,10 +128,10 @@ RSpec.shared_examples "redis_shared_examples" do
end end
end end
context 'when running on sidekiq workers' do context 'when running on multi-threaded runtime' do
before do before do
allow(Gitlab::Runtime).to receive(:sidekiq?).and_return(true) allow(Gitlab::Runtime).to receive(:multi_threaded?).and_return(true)
allow(Sidekiq).to receive(:options).and_return({ concurrency: 18 }) allow(Gitlab::Runtime).to receive(:max_threads).and_return(18)
end end
it 'instantiates a connection pool with a size based on the concurrency of the worker' do it 'instantiates a connection pool with a size based on the concurrency of the worker' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment