Class: HeapScope::GCTracker

Inherits:
Object
  • Object
show all
Defined in:
lib/heapscope/aging.rb

Overview

Tracks GC stats around workloads for recovery correlation.

Instance Method Summary collapse

Constructor Details

#initializeGCTracker

Returns a new instance of GCTracker.



74
75
76
# File 'lib/heapscope/aging.rb', line 74

def initialize
  @points = []
end

Instance Method Details

#correlationObject



92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/heapscope/aging.rb', line 92

def correlation
  return {} if @points.size < 2

  first = @points.first
  last = @points.last
  {
    points: @points,
    major_gc_delta: delta(last[:gc_stat][:major_gc_count], first[:gc_stat][:major_gc_count]),
    minor_gc_delta: delta(last[:gc_stat][:minor_gc_count], first[:gc_stat][:minor_gc_count]),
    live_slots_delta: delta(last[:gc_stat][:heap_live_slots], first[:gc_stat][:heap_live_slots]),
    rss_delta: delta(last[:rss_bytes], first[:rss_bytes])
  }
end

#mark(label) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/heapscope/aging.rb', line 78

def mark(label)
  @points << {
    label: label,
    at: Time.now.utc,
    gc_stat: Runtime.current.gc_stat.dup,
    rss_bytes: begin
      Runtime.current.rss_bytes
    rescue StandardError
      nil
    end
  }
  self
end