Sha256: 09f23bf1d5ee79badfd9d59ad34c8d8d5e5f85ada2c7c6d77875f97b5a398315
Contents?: true
Size: 1.04 KB
Versions: 3
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true module Pitchfork module MoldSelector class LeastSharedMemory def call(server) workers = server.children.fresh_workers if workers.empty? server.logger.info("No current generation workers yet") return end candidate = workers.shift workers.each do |worker| if worker.meminfo.shared_memory < candidate.meminfo.shared_memory # We suppose that a worker with a lower amount of shared memory # has warmed up more caches & such, hence is closer to stabilize # making it a better candidate. candidate = worker end end parent_meminfo = server.children.mold&.meminfo || MemInfo.new(Process.pid) cow_efficiency = candidate.meminfo.cow_efficiency(parent_meminfo) server.logger.info("worker=#{candidate.nr} pid=#{candidate.pid} selected as new mold shared_memory_kb=#{candidate.meminfo.shared_memory} cow=#{cow_efficiency.round(1)}%") candidate end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pitchfork-0.1.2 | lib/pitchfork/mold_selector.rb |
pitchfork-0.1.1 | lib/pitchfork/mold_selector.rb |
pitchfork-0.1.0 | lib/pitchfork/mold_selector.rb |