Skip to content

Instantly share code, notes, and snippets.

@akrzos
Created October 1, 2015 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akrzos/d86e99174365d0e3e2a3 to your computer and use it in GitHub Desktop.
Save akrzos/d86e99174365d0e3e2a3 to your computer and use it in GitHub Desktop.
[root@dhcp23-166 vmdb]# bundle exec bin/rails c
DEPRECATION WARNING: You did not specify a `log_level` in `production.rb`. Currently, the default value for `log_level` is `:info` for the production environment and `:debug` in all other environments. In Rails 5 the default value will be unified to `:debug` across all environments. To preserve the current setting, add the following line to your `production.rb`:
config.log_level = :info
. (called from block in tsort_each at /opt/rh/rh-ruby22/root/usr/share/ruby/tsort.rb:226)
Loading production environment (Rails 4.2.4)
irb(main):001:0> ActiveRecord::Base.logger.level = 1
=> 1
irb(main):002:0> require "objspace"
=> true
irb(main):003:0> mrss_start = MiqProcess.processInfo()[:memory_usage]
=> 176586752
irb(main):004:0> vrss_start = MiqProcess.processInfo[:memory_size]
=> 482246656
irb(main):005:0> GC.stat
=> {:count=>35, :heap_allocated_pages=>2177, :heap_sorted_length=>2460, :heap_allocatable_pages=>0, :heap_available_slots=>887350, :heap_live_slots=>887194, :heap_free_slots=>156, :heap_final_slots=>0, :heap_marked_slots=>560763, :heap_swept_slots=>304550, :heap_eden_pages=>2177, :heap_tomb_pages=>0, :total_allocated_pages=>2400, :total_freed_pages=>223, :total_allocated_objects=>6841231, :total_freed_objects=>5954037, :malloc_increase_bytes=>191008, :malloc_increase_bytes_limit=>27995515, :minor_gc_count=>25, :major_gc_count=>10, :remembered_wb_unprotected_objects=>20599, :remembered_wb_unprotected_objects_limit=>38792, :old_objects=>521834, :old_objects_limit=>949414, :oldmalloc_increase_bytes=>191456, :oldmalloc_increase_bytes_limit=>27318891}
irb(main):006:0> e = ExtManagementSystem.find_by_name('vmware-small')
=> #<ManageIQ::Providers::Vmware::InfraManager id: 1, name: "vmware-small", port: nil, hostname: "10.12.20.65", ipaddress: nil, created_on: "2015-10-01 15:50:23", updated_on: "2015-10-01 15:50:23", guid: "20650ec8-6854-11e5-9d9f-0001a4ae7105", zone_id: 1, type: "ManageIQ::Providers::Vmware::InfraManager", api_version: nil, uid_ems: nil, host_default_vnc_port_start: nil, host_default_vnc_port_end: nil, provider_region: nil, last_refresh_error: nil, last_refresh_date: nil, provider_id: nil, security_protocol: nil, realm: nil, tenant_id: nil>
irb(main):007:0> timing = Benchmark.realtime { EmsRefresh.refresh e }
=> 12.009618730982766
irb(main):008:0> mrss_end = MiqProcess.processInfo()[:memory_usage]
=> 275042304
irb(main):009:0> vrss_end = MiqProcess.processInfo[:memory_size]
=> 648536064
irb(main):010:0> GC.stat
=> {:count=>44, :heap_allocated_pages=>3852, :heap_sorted_length=>3918, :heap_allocatable_pages=>0, :heap_available_slots=>1570071, :heap_live_slots=>1567512, :heap_free_slots=>2559, :heap_final_slots=>0, :heap_marked_slots=>798911, :heap_swept_slots=>308347, :heap_eden_pages=>3849, :heap_tomb_pages=>3, :total_allocated_pages=>4075, :total_freed_pages=>223, :total_allocated_objects=>11998153, :total_freed_objects=>10430641, :malloc_increase_bytes=>5775736, :malloc_increase_bytes_limit=>30949538, :minor_gc_count=>33, :major_gc_count=>11, :remembered_wb_unprotected_objects=>28029, :remembered_wb_unprotected_objects_limit=>47976, :old_objects=>744901, :old_objects_limit=>1215580, :oldmalloc_increase_bytes=>13853208, :oldmalloc_increase_bytes_limit=>26783226}
irb(main):011:0> mrss_change = mrss_end - mrss_start
=> 98455552
irb(main):012:0> vrss_change = vrss_end - vrss_start
=> 166289408
irb(main):013:0> puts "#{mrss_start}, #{mrss_end}, #{mrss_change}"
176586752, 275042304, 98455552
=> nil
irb(main):014:0> puts "#{vrss_start}, #{vrss_end}, #{vrss_change}"
482246656, 648536064, 166289408
=> nil
irb(main):015:0> puts timing
12.009618730982766
=> nil
irb(main):016:0> ObjectSpace.count_tdata_objects
=> {RubyVM::InstructionSequence=>56616, Proc=>27904, RubyVM::Env=>26891, UnboundMethod=>602, Mutex=>2449, :autoload_i=>484, Time=>2844, Encoding=>100, ThreadGroup=>2, Binding=>3, Thread=>2, RubyVM=>1, :iseq=>1, Random=>1, ARGF.class=>1, Data=>3, :autoload=>68, OpenSSL::X509::Store=>1, :unknown=>5, PG::Connection=>1, Method=>1391, Thread::Backtrace=>108, OpenSSL::Cipher::Cipher=>1, FFI::Pointer=>1, FFI::Type::Builtin=>21, FFI::Type::Mapped=>1, FFI::ArrayType=>6, FFI::StructLayout::Array=>6, FFI::FunctionType=>3, FFI::Function=>3, FFI::DynamicLibrary::Symbol=>3, FFI::DynamicLibrary=>1, FFI::StructLayout=>1, DateTime=>1, Object=>32, PG::TypeMapAllStrings=>1, :thread_shield=>8, :mutex=>8, BigDecimal=>2, JSON::Ext::Generator::State=>3, PG::BinaryDecoder::Float=>2, PG::BinaryDecoder::Boolean=>1, PG::BinaryEncoder::Boolean=>1, PG::BinaryDecoder::Bytea=>1, PG::BinaryEncoder::Bytea=>1, PG::BinaryDecoder::String=>1, PG::BinaryEncoder::String=>1, PG::BinaryDecoder::Integer=>3, PG::BinaryEncoder::Int8=>1, PG::BinaryEncoder::Int4=>1, PG::BinaryEncoder::Int2=>1, PG::TextDecoder::Date=>1, PG::TextEncoder::Date=>1, PG::TextDecoder::TimestampWithTimeZone=>1, PG::TextEncoder::TimestampWithTimeZone=>1, PG::TextDecoder::TimestampWithoutTimeZone=>1, PG::TextEncoder::TimestampWithoutTimeZone=>1, PG::TextDecoder::Float=>1, PG::TextEncoder::Float=>1, PG::TextDecoder::Boolean=>1, PG::TextEncoder::Boolean=>1, PG::TextDecoder::Bytea=>1, PG::TextDecoder::String=>1, PG::TextEncoder::String=>1, PG::TextDecoder::Integer=>1, PG::TextEncoder::Integer=>1, PG::Result=>351, Psych::Emitter=>1300, StringIO=>1300, Psych::Parser=>200, Enumerator=>159, :parser=>429, Thread::Backtrace::Location=>106}
irb(main):017:0> ObjectSpace.count_objects_size
=> {:T_OBJECT=>8776496, :T_CLASS=>12017192, :T_MODULE=>2902400, :T_FLOAT=>440, :T_STRING=>26678503, :T_REGEXP=>3227319, :T_ARRAY=>14708368, :T_HASH=>25763296, :T_STRUCT=>443168, :T_BIGNUM=>38400, :T_FILE=>66464, :T_DATA=>72754121, :T_MATCH=>722624, :T_COMPLEX=>40, :T_RATIONAL=>44960, :T_SYMBOL=>112320, :T_NODE=>3183672, :T_ICLASS=>187920, :TOTAL=>171627703}
irb(main):018:0> ObjectSpace.memsize_of_all(String)
=> 26691571
irb(main):019:0> ObjectSpace.memsize_of_all
=> 161939229
irb(main):020:0>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment