diff --git a/lib/vmpooler/pool_manager.rb b/lib/vmpooler/pool_manager.rb index 0580d332..ed2fe704 100644 --- a/lib/vmpooler/pool_manager.rb +++ b/lib/vmpooler/pool_manager.rb @@ -12,6 +12,11 @@ class PoolManager CHECK_LOOP_DELAY_MAX_DEFAULT = 60 CHECK_LOOP_DELAY_DECAY_DEFAULT = 2.0 + # Number of pre-allocated mutexes that ondemand request_ids are hashed + # across. See #request_mutex for why this is striped rather than a + # per-request_id map. + REQUEST_MUTEX_STRIPE_COUNT = 256 + def initialize(config, logger, redis_connection_pool, metrics) $config = config @@ -34,9 +39,10 @@ def initialize(config, logger, redis_connection_pool, metrics) $threads = Concurrent::Hash.new # Pool mutex - @reconfigure_pool = Concurrent::Hash.new + @reconfigure_pool = Concurrent::Map.new - @vm_mutex = Concurrent::Hash.new + @vm_mutex = Concurrent::Map.new + @request_mutex_stripes = Array.new(REQUEST_MUTEX_STRIPE_COUNT) { Mutex.new } # Name generator for generating host names @name_generator = Spicy::Proton.new @@ -242,29 +248,34 @@ def move_pending_vm_to_ready(vm, pool, redis, request_id = nil) finish = format('%