memory_tracker 1.2.4 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/controllers/memory_tracker/dashboards_controller.rb +1 -1
- data/lib/memory_tracker/gc_stat.rb +62 -8
- data/lib/memory_tracker/stores/gcstat_logfile_store.rb +1 -1
- data/lib/memory_tracker/stores/url_logfile_store.rb +2 -2
- data/lib/memory_tracker/version.rb +1 -1
- data/spec/lib/request_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d034885b36b92cbe3e175ffdb7fb26890e3ba1a
|
4
|
+
data.tar.gz: 037010fff3c82ee9a487d6b36cd4abe37beaeee8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dffc3d046e6a7622d6379c1c0dad2e3d175603f9b10b1516b6f7329f0b53b860759a07069087f5b6174977365ce42551ec410ce93c351b3664caea88639f7d5
|
7
|
+
data.tar.gz: 7ec5aaa4cde2bdf10d8d828c3f6d33c1318d34110028c6b90cc1ccdfd440a88fc4161cbce41a37ff3748b4792edf234c9bd1a2b53b947d5a1ba6a89d8644e921
|
data/Gemfile.lock
CHANGED
@@ -1,20 +1,74 @@
|
|
1
1
|
module MemoryTracker
|
2
2
|
class GcStat
|
3
|
-
|
3
|
+
|
4
|
+
include Enumerable
|
5
|
+
|
6
|
+
RUBY22_TO_CANONICAL_MAPPING = { total_allocated_objects: :total_allocated_object,
|
7
|
+
total_freed_objects: :total_freed_object,
|
8
|
+
heap_allocated_pages: :heap_used,
|
9
|
+
heap_live_slots: :heap_live_num,
|
10
|
+
heap_free_slots: :heap_free_num,
|
11
|
+
heap_final_slots: :heap_final_num,
|
12
|
+
heap_sorted_length: :heap_length
|
13
|
+
}
|
14
|
+
CANONICAL_TO_RUBY22_MAPPING = RUBY22_TO_CANONICAL_MAPPING.invert
|
4
15
|
|
5
16
|
def initialize(rss, vsize)
|
6
17
|
@stats = GC.stat.merge({ :rss => rss, :vsize => vsize})
|
7
18
|
end
|
8
19
|
|
20
|
+
def each(&block)
|
21
|
+
@stats.each do |k, v|
|
22
|
+
yield canonical_key_name(k), v
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def keys
|
27
|
+
@stats.keys
|
28
|
+
end
|
29
|
+
|
9
30
|
def ordered_keys
|
10
|
-
@stats.keys.sort
|
31
|
+
@stats.keys.map { |k| canonical_key_name(k) }.sort
|
11
32
|
end
|
12
33
|
|
13
34
|
def ordered_values(ordered_columns = ordered_keys)
|
14
35
|
ordered_columns.inject([]) do |vals, key|
|
15
|
-
vals << @stats[key]
|
16
|
-
|
36
|
+
vals << @stats[current_version_key_name(key)]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def [](key)
|
41
|
+
@stats[current_version_key_name(key)]
|
42
|
+
end
|
43
|
+
|
44
|
+
def canonical_key_name(key)
|
45
|
+
self.class.canonical_key_name(key)
|
46
|
+
end
|
47
|
+
|
48
|
+
def current_version_key_name(key)
|
49
|
+
self.class.current_version_key_name(key)
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.canonical_key_name(key)
|
53
|
+
canonical = key
|
54
|
+
case RUBY_VERSION
|
55
|
+
when /\A2\.2\./
|
56
|
+
canonical = RUBY22_TO_CANONICAL_MAPPING.fetch(key, key)
|
17
57
|
end
|
58
|
+
canonical
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.current_version_key_name(key)
|
62
|
+
current_key_name = key
|
63
|
+
case RUBY_VERSION
|
64
|
+
when /\A2\.2\./
|
65
|
+
current_key_name = CANONICAL_TO_RUBY22_MAPPING.fetch(key, key)
|
66
|
+
end
|
67
|
+
current_key_name
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.heap_used
|
71
|
+
GC.stat[current_version_key_name(:heap_used)]
|
18
72
|
end
|
19
73
|
|
20
74
|
def self.gcdiff(before, after)
|
@@ -43,8 +97,8 @@ module MemoryTracker
|
|
43
97
|
|
44
98
|
def initialize(before, after)
|
45
99
|
@after = after
|
46
|
-
@stats = after.
|
47
|
-
h[k] = after
|
100
|
+
@stats = after.inject({}) do |h, (k, v)|
|
101
|
+
h[k] = after[k] - before[k]
|
48
102
|
h
|
49
103
|
end
|
50
104
|
end
|
@@ -55,8 +109,8 @@ module MemoryTracker
|
|
55
109
|
h[:total_allocated_object] = stats[:total_allocated_object]
|
56
110
|
h[:count] = stats[:count]
|
57
111
|
h[:rss] = stats[:rss]
|
58
|
-
h[:heap_used] = @after
|
59
|
-
h[:in_use] = @after
|
112
|
+
h[:heap_used] = @after[:heap_used]
|
113
|
+
h[:in_use] = @after[:total_allocated_object] - @after[:total_freed_object]
|
60
114
|
h
|
61
115
|
end
|
62
116
|
end
|
@@ -3,7 +3,7 @@ module MemoryTracker
|
|
3
3
|
class GcstatLogfileStore < Base
|
4
4
|
register_store :gcstat_logfile
|
5
5
|
|
6
|
-
COLUMNS = [ :count, :heap_final_num, :heap_free_num, :
|
6
|
+
COLUMNS = [ :count, :heap_final_num, :heap_free_num, :heap_length, :heap_live_num, :heap_used, :rss, :total_allocated_object, :total_freed_object, :vsize ]
|
7
7
|
|
8
8
|
def initialize(opts)
|
9
9
|
logger_class = opts.fetch(:logger_class, 'Logger')
|
@@ -32,8 +32,8 @@ module MemoryTracker
|
|
32
32
|
def logline
|
33
33
|
pid = Process.pid
|
34
34
|
|
35
|
-
end_gcstats = @request.end_gcstat
|
36
|
-
start_gcstats = @request.start_gcstat
|
35
|
+
end_gcstats = @request.end_gcstat
|
36
|
+
start_gcstats = @request.start_gcstat
|
37
37
|
delta_gcstats = @request.gcstat_delta.stats
|
38
38
|
|
39
39
|
log_msg = "#{Time.now.localtime.strftime("%m-%d %H:%M:%S")} pid:#{'%05d' % pid}"
|
data/spec/lib/request_spec.rb
CHANGED
@@ -9,8 +9,8 @@ module MemoryTracker
|
|
9
9
|
|
10
10
|
it 'should initalize start_gcstat' do
|
11
11
|
@request.start_gcstat.should be_a(GcStat)
|
12
|
-
@request.start_gcstat.
|
13
|
-
@request.start_gcstat.
|
12
|
+
@request.start_gcstat.keys.should include :rss
|
13
|
+
@request.start_gcstat.keys.should include :vsize
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'should have a controller' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: memory_tracker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philippe Le Rohellec
|
@@ -155,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
155
|
version: '0'
|
156
156
|
requirements: []
|
157
157
|
rubyforge_project:
|
158
|
-
rubygems_version: 2.
|
158
|
+
rubygems_version: 2.4.6
|
159
159
|
signing_key:
|
160
160
|
specification_version: 4
|
161
161
|
summary: Rails memory allocations tracker
|