From 5e262265a2f9b85c110bfc039ed65d093bce022c Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 27 Jul 2018 12:51:06 +1000 Subject: [PATCH] update script to provide more mem stats --- script/mwrap_sidekiq | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/script/mwrap_sidekiq b/script/mwrap_sidekiq index 318e483366a..1249a3c8d89 100755 --- a/script/mwrap_sidekiq +++ b/script/mwrap_sidekiq @@ -1,6 +1,9 @@ #!/usr/bin/env ruby if !ENV["LD_PRELOAD"]&.include?('mwrap') + # use malloc from libc that interacts better with mwrap ENV['RAILS_ENV'] = 'production' + ENV["LD_PRELOAD"] = "" + ENV["MALLOC_ARENA_MAX"] = "2" exec "mwrap #{__FILE__}" end @@ -47,11 +50,16 @@ def render_table(array) buffer end +def rss + `ps -o rss= -p #{Process.pid}`.chomp.to_i +end + def mwrap_log report = +"" Mwrap.quiet do - report << "Generation: #{GC.count}\n\n" + report << "Generation: #{GC.count} RSS kb: #{rss} Accounted Mem kb: #{(Mwrap.total_bytes_allocated - Mwrap.total_bytes_freed) / 1024}\n" + report << "Allocated bytes: #{Mwrap.total_bytes_allocated} Freed bytes: #{Mwrap.total_bytes_freed}\n\n" table = [] Mwrap.each(200) do |loc, total, allocations, frees, age_sum, max_life|