Comment out

This commit is contained in:
Wedge 2016-06-12 15:14:10 +03:00
parent 6758bec8a4
commit 74313e2369
1 changed files with 40 additions and 40 deletions

View File

@ -15,49 +15,49 @@ if ENV["PROFILE"]
ObjectSpace.trace_object_allocations_start ObjectSpace.trace_object_allocations_start
Sidekiq.logger.info "allocations tracing enabled" Sidekiq.logger.info "allocations tracing enabled"
module Sidekiq # module Sidekiq
module Middleware # module Middleware
module Server # module Server
class Profiler # class Profiler
# Number of jobs to process before reporting # # Number of jobs to process before reporting
JOBS = 100 # JOBS = 100
class << self # class << self
mattr_accessor :counter # mattr_accessor :counter
self.counter = 0 # self.counter = 0
def synchronize(&block) # def synchronize(&block)
@lock ||= Mutex.new # @lock ||= Mutex.new
@lock.synchronize(&block) # @lock.synchronize(&block)
end # end
end # end
def call(worker_instance, item, queue) # def call(worker_instance, item, queue)
begin # begin
yield # yield
ensure # ensure
self.class.synchronize do # self.class.synchronize do
self.class.counter += 1 # self.class.counter += 1
if self.class.counter % JOBS == 0 # if self.class.counter % JOBS == 0
Sidekiq.logger.info "reporting allocations after #{self.class.counter} jobs" # Sidekiq.logger.info "reporting allocations after #{self.class.counter} jobs"
GC.start # GC.start
out = File.open("/tmp/heap.json", "w") # out = File.open("/tmp/heap.json", "w")
ObjectSpace.dump_all(output: out) # ObjectSpace.dump_all(output: out)
out.close # out.close
Sidekiq.logger.info "heap saved to heap.json" # Sidekiq.logger.info "heap saved to heap.json"
end # end
end # end
end # end
end # end
end # end
end # end
end # end
end # end
Sidekiq.configure_server do |config| # Sidekiq.configure_server do |config|
config.server_middleware do |chain| # config.server_middleware do |chain|
chain.add Sidekiq::Middleware::Server::Profiler # chain.add Sidekiq::Middleware::Server::Profiler
end # end
end # end
end end