mirror of
https://github.com/discourse/discourse.git
synced 2025-02-16 23:42:44 +08:00
update script to provide more mem stats
This commit is contained in:
parent
6f9a91cbd5
commit
5e262265a2
|
@ -1,6 +1,9 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
if !ENV["LD_PRELOAD"]&.include?('mwrap')
|
if !ENV["LD_PRELOAD"]&.include?('mwrap')
|
||||||
|
# use malloc from libc that interacts better with mwrap
|
||||||
ENV['RAILS_ENV'] = 'production'
|
ENV['RAILS_ENV'] = 'production'
|
||||||
|
ENV["LD_PRELOAD"] = ""
|
||||||
|
ENV["MALLOC_ARENA_MAX"] = "2"
|
||||||
exec "mwrap #{__FILE__}"
|
exec "mwrap #{__FILE__}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -47,11 +50,16 @@ def render_table(array)
|
||||||
buffer
|
buffer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def rss
|
||||||
|
`ps -o rss= -p #{Process.pid}`.chomp.to_i
|
||||||
|
end
|
||||||
|
|
||||||
def mwrap_log
|
def mwrap_log
|
||||||
report = +""
|
report = +""
|
||||||
|
|
||||||
Mwrap.quiet do
|
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 = []
|
table = []
|
||||||
Mwrap.each(200) do |loc, total, allocations, frees, age_sum, max_life|
|
Mwrap.each(200) do |loc, total, allocations, frees, age_sum, max_life|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user