tunemygc 1.0.4 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +5 -1
- data/ext/tunemygc/extconf.rb +2 -2
- data/lib/tunemygc/snapshotter.rb +5 -2
- data/lib/tunemygc/syncer.rb +5 -1
- data/lib/tunemygc/version.rb +1 -1
- data/test/fixtures.rb +1 -1
- data/test/test_snapshotter.rb +2 -0
- data/test/test_syncer.rb +7 -7
- 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: f335f0a411ceb5bd4af313a30c3c7df9accd3aff
|
4
|
+
data.tar.gz: 208ddfc32ef3e24bd7fbe1e31b4560d6b00b3253
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e261548fe3b52cbb58c93ef5be2e58600f184ea7a5e20c91e5f2817983338547a08dc5c23e2a4cbc78f057cb33d6544b5ffb4ca33d018843253e4509d639837a
|
7
|
+
data.tar.gz: c8959c605ba3bd607589ff3efacb16a658e65fe4a5c0f1738ad0be5ded8def2d5796b95ea8a33e5043b73b1528ea2edf9facbd734d4e5d724f755a812fadad87
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -186,4 +186,8 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
186
186
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
187
187
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
188
188
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
189
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
189
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
190
|
+
|
191
|
+
## Credits
|
192
|
+
|
193
|
+
RSS measuring feature by David Robert Nadeau (http://NadeauSoftware.com/) under Creative Commons Attribution 3.0 Unported License (http://creativecommons.org/licenses/by/3.0/deed.en_US)
|
data/ext/tunemygc/extconf.rb
CHANGED
@@ -49,11 +49,11 @@ if gc_events
|
|
49
49
|
f.puts "tunemygc_get_stat_record(tunemygc_stat_record *record)"
|
50
50
|
f.puts "{"
|
51
51
|
#
|
52
|
-
f.puts " VALUE stat =
|
52
|
+
f.puts " VALUE stat = rb_ary_new2(#{gc_stat.keys.size});"
|
53
53
|
f.puts " VALUE latest_info = rb_hash_new();"
|
54
54
|
f.puts " VALUE snapshot = rb_ary_new2(7);"
|
55
55
|
gc_stat.keys.each.with_index{|k, i|
|
56
|
-
f.puts "
|
56
|
+
f.puts " rb_ary_store(stat, #{i}, SIZET2NUM(record->#{k}));"
|
57
57
|
}
|
58
58
|
gc_latest_info.keys.each.with_index{|k, i|
|
59
59
|
f.puts " rb_hash_aset(latest_info, sym_latest_gc_info[#{i}], record->#{k});"
|
data/lib/tunemygc/snapshotter.rb
CHANGED
@@ -5,18 +5,21 @@ require 'thread'
|
|
5
5
|
module TuneMyGc
|
6
6
|
class Snapshotter
|
7
7
|
UNITS_OF_WORK = /REQUEST_PROCESSING_STARTED|REQUEST_PROCESSING_ENDED/
|
8
|
+
TERMINATED = /TERMINATED/
|
8
9
|
MAX_SAMPLES = (ENV['RUBY_GC_MAX_SAMPLES'] ? Integer(ENV['RUBY_GC_MAX_SAMPLES']) : 2000)
|
9
10
|
|
10
11
|
attr_reader :buffer
|
11
12
|
attr_accessor :unit_of_work
|
13
|
+
attr_reader :stat_keys
|
12
14
|
|
13
15
|
def initialize(buf = Queue.new)
|
14
16
|
@buffer = buf
|
15
17
|
@unit_of_work = false
|
18
|
+
@stat_keys = GC.stat.keys
|
16
19
|
end
|
17
20
|
|
18
21
|
def take(stage, timestamp = nil, meta = nil)
|
19
|
-
_buffer([(timestamp || TuneMyGc.walltime), TuneMyGc.peak_rss, TuneMyGc.current_rss, stage, GC.stat, GC.latest_gc_info, meta])
|
22
|
+
_buffer([(timestamp || TuneMyGc.walltime), TuneMyGc.peak_rss, TuneMyGc.current_rss, stage, GC.stat.values_at(*stat_keys), GC.latest_gc_info, meta])
|
20
23
|
end
|
21
24
|
|
22
25
|
# low level interface, for tests and GC callback
|
@@ -42,7 +45,7 @@ module TuneMyGc
|
|
42
45
|
|
43
46
|
private
|
44
47
|
def _buffer(snapshot)
|
45
|
-
if size < MAX_SAMPLES
|
48
|
+
if snapshot[3] =~ TERMINATED || size < MAX_SAMPLES
|
46
49
|
self.unit_of_work = true if snapshot[3] =~ UNITS_OF_WORK
|
47
50
|
@buffer << snapshot
|
48
51
|
else
|
data/lib/tunemygc/syncer.rb
CHANGED
@@ -38,6 +38,10 @@ module TuneMyGc
|
|
38
38
|
snapshotter.unit_of_work
|
39
39
|
end
|
40
40
|
|
41
|
+
def environment(snapshotter)
|
42
|
+
ENVIRONMENT.dup.push(snapshotter.stat_keys)
|
43
|
+
end
|
44
|
+
|
41
45
|
private
|
42
46
|
def timeout(&block)
|
43
47
|
Timeout.timeout(TIMEOUT + 1){ block.call }
|
@@ -48,7 +52,7 @@ module TuneMyGc
|
|
48
52
|
# Fallback to Timeout if Net::HTTP read timeout fails
|
49
53
|
snapshots = snapshotter.size
|
50
54
|
TuneMyGc.log "Syncing #{snapshots} snapshots"
|
51
|
-
payload = [
|
55
|
+
payload = [environment(snapshotter)]
|
52
56
|
debug = ENV["RUBY_GC_TUNE_DEBUG"]
|
53
57
|
TuneMyGc.log "=== Snapshots ===" if debug
|
54
58
|
while !snapshotter.empty?
|
data/lib/tunemygc/version.rb
CHANGED
data/test/fixtures.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'time'
|
4
4
|
|
5
5
|
module Fixtures
|
6
|
-
STAGE_BOOTED = [1420152606.1162581, "BOOTED",
|
6
|
+
STAGE_BOOTED = [1420152606.1162581, "BOOTED", [32,950,1519,569,385225,2014,0,101119,950,0,2184137,1798912,9665288,16777216,26,6,5145,6032,230164,301030,11715304,24159190], {"major_by"=>nil, "gc_by"=>"newobj", "have_finalizer"=>false, "immediate_sweep"=>false}, nil]
|
7
7
|
|
8
8
|
CONFIG = {"Memory"=>{"RUBY_GC_HEAP_INIT_SLOTS"=>307562,"RUBY_GC_HEAP_FREE_SLOTS"=>6151,"RUBY_GC_HEAP_GROWTH_FACTOR"=>0.07,"RUBY_GC_HEAP_GROWTH_MAX_SLOTS"=>6151,"RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR"=>0.11,"RUBY_GC_MALLOC_LIMIT"=>2000000,"RUBY_GC_MALLOC_LIMIT_MAX"=>4000000,"RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR"=>0.11,"RUBY_GC_OLDMALLOC_LIMIT"=>2000000,"RUBY_GC_OLDMALLOC_LIMIT_MAX"=>4000000,"RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR"=>0.11},"Speed"=>{"RUBY_GC_HEAP_INIT_SLOTS"=>369074,"RUBY_GC_HEAP_FREE_SLOTS"=>184537,"RUBY_GC_HEAP_GROWTH_FACTOR"=>1.2,"RUBY_GC_HEAP_GROWTH_MAX_SLOTS"=>123024,"RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR"=>2.0,"RUBY_GC_MALLOC_LIMIT"=>64000000,"RUBY_GC_MALLOC_LIMIT_MAX"=>128000000,"RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR"=>1.2,"RUBY_GC_OLDMALLOC_LIMIT"=>64000000,"RUBY_GC_OLDMALLOC_LIMIT_MAX"=>128000000,"RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR"=>1.2}, "callback"=>"https://tunemygc.com/configs/8d07e13cc5a7bba2da3510b9ca5e75f4.json"}
|
9
9
|
end
|
data/test/test_snapshotter.rb
CHANGED
data/test/test_syncer.rb
CHANGED
@@ -28,7 +28,7 @@ class TestSyncer < TuneMyGcTestCase
|
|
28
28
|
to_return(:status => 200, :body => ActiveSupport::JSON.encode({:Memory=>{:RUBY_GC_HEAP_INIT_SLOTS=>477268, :RUBY_GC_HEAP_FREE_SLOTS=>106607, :RUBY_GC_HEAP_GROWTH_FACTOR=>1.05, :RUBY_GC_HEAP_GROWTH_MAX_SLOTS=>10661, :RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=>1.05, :RUBY_GC_MALLOC_LIMIT=>2000000, :RUBY_GC_MALLOC_LIMIT_MAX=>4000000, :RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR=>1.1, :RUBY_GC_OLDMALLOC_LIMIT=>2000000, :RUBY_GC_OLDMALLOC_LIMIT_MAX=>4000000, :RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR=>1.05}, :Speed=>{:RUBY_GC_HEAP_INIT_SLOTS=>572722, :RUBY_GC_HEAP_FREE_SLOTS=>553800, :RUBY_GC_HEAP_GROWTH_FACTOR=>1.2, :RUBY_GC_HEAP_GROWTH_MAX_SLOTS=>83070, :RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=>2.0, :RUBY_GC_MALLOC_LIMIT=>64000000, :RUBY_GC_MALLOC_LIMIT_MAX=>128000000, :RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR=>1.56, :RUBY_GC_OLDMALLOC_LIMIT=>64000000, :RUBY_GC_OLDMALLOC_LIMIT_MAX=>33554432, :RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR=>1.32}}), :headers => {})
|
29
29
|
|
30
30
|
stub_request(:post, "https://tunemygc.com/ruby").
|
31
|
-
with(:body => "[#{ActiveSupport::JSON.encode(
|
31
|
+
with(:body => "[#{ActiveSupport::JSON.encode(syncer.environment(snapshots))},[1420152606.1162581,\"BOOTED\",[32,950,1519,569,385225,2014,0,101119,950,0,2184137,1798912,9665288,16777216,26,6,5145,6032,230164,301030,11715304,24159190],{\"major_by\":null,\"gc_by\":\"newobj\",\"have_finalizer\":false,\"immediate_sweep\":false},null]]",
|
32
32
|
:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/json', 'User-Agent'=>"TuneMyGC #{TuneMyGc::VERSION}"}).
|
33
33
|
to_return(:status => 200, :body => "https://www.tunemygc.com/configs/xxxxxxx", :headers => {})
|
34
34
|
|
@@ -46,7 +46,7 @@ class TestSyncer < TuneMyGcTestCase
|
|
46
46
|
snapshots = TuneMyGc::Snapshotter.new
|
47
47
|
snapshots.take_raw(Fixtures::STAGE_BOOTED)
|
48
48
|
stub_request(:post, "https://tunemygc.com/ruby").
|
49
|
-
with(:body => "[#{ActiveSupport::JSON.encode(
|
49
|
+
with(:body => "[#{ActiveSupport::JSON.encode(syncer.environment(snapshots))},[1420152606.1162581,\"BOOTED\",[32,950,1519,569,385225,2014,0,101119,950,0,2184137,1798912,9665288,16777216,26,6,5145,6032,230164,301030,11715304,24159190],{\"major_by\":null,\"gc_by\":\"newobj\",\"have_finalizer\":false,\"immediate_sweep\":false},null]]",
|
50
50
|
:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/json', 'User-Agent'=>"TuneMyGC #{TuneMyGc::VERSION}"}).
|
51
51
|
to_return(:status => 501, :body => "", :headers => {})
|
52
52
|
|
@@ -65,7 +65,7 @@ class TestSyncer < TuneMyGcTestCase
|
|
65
65
|
snapshots = TuneMyGc::Snapshotter.new
|
66
66
|
snapshots.take_raw(Fixtures::STAGE_BOOTED)
|
67
67
|
stub_request(:post, "https://tunemygc.com/ruby").
|
68
|
-
with(:body => "[#{ActiveSupport::JSON.encode(
|
68
|
+
with(:body => "[#{ActiveSupport::JSON.encode(syncer.environment(snapshots))},[1420152606.1162581,\"BOOTED\",[32,950,1519,569,385225,2014,0,101119,950,0,2184137,1798912,9665288,16777216,26,6,5145,6032,230164,301030,11715304,24159190],{\"major_by\":null,\"gc_by\":\"newobj\",\"have_finalizer\":false,\"immediate_sweep\":false},null]]",
|
69
69
|
:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/json', 'User-Agent'=>"TuneMyGC #{TuneMyGc::VERSION}"}).
|
70
70
|
to_return(:status => 412, :body => "", :headers => {})
|
71
71
|
|
@@ -82,7 +82,7 @@ class TestSyncer < TuneMyGcTestCase
|
|
82
82
|
snapshots = TuneMyGc::Snapshotter.new
|
83
83
|
snapshots.take_raw(Fixtures::STAGE_BOOTED)
|
84
84
|
stub_request(:post, "https://tunemygc.com/ruby").
|
85
|
-
with(:body => "[#{ActiveSupport::JSON.encode(
|
85
|
+
with(:body => "[#{ActiveSupport::JSON.encode(syncer.environment(snapshots))},[1420152606.1162581,\"BOOTED\",[32,950,1519,569,385225,2014,0,101119,950,0,2184137,1798912,9665288,16777216,26,6,5145,6032,230164,301030,11715304,24159190],{\"major_by\":null,\"gc_by\":\"newobj\",\"have_finalizer\":false,\"immediate_sweep\":false},null]]",
|
86
86
|
:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/json', 'User-Agent'=>"TuneMyGC #{TuneMyGc::VERSION}"}).
|
87
87
|
to_return(:status => 400, :body => "snapshot timestamp", :headers => {})
|
88
88
|
|
@@ -100,7 +100,7 @@ class TestSyncer < TuneMyGcTestCase
|
|
100
100
|
snapshots = TuneMyGc::Snapshotter.new
|
101
101
|
snapshots.take_raw(Fixtures::STAGE_BOOTED)
|
102
102
|
stub_request(:post, "https://tunemygc.com/ruby").
|
103
|
-
with(:body => "[#{ActiveSupport::JSON.encode(
|
103
|
+
with(:body => "[#{ActiveSupport::JSON.encode(syncer.environment(snapshots))},[1420152606.1162581,\"BOOTED\",[32,950,1519,569,385225,2014,0,101119,950,0,2184137,1798912,9665288,16777216,26,6,5145,6032,230164,301030,11715304,24159190],{\"major_by\":null,\"gc_by\":\"newobj\",\"have_finalizer\":false,\"immediate_sweep\":false},null]]",
|
104
104
|
:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/json', 'User-Agent'=>"TuneMyGC #{TuneMyGc::VERSION}"}).
|
105
105
|
to_return(:status => 404, :body => "", :headers => {})
|
106
106
|
|
@@ -116,7 +116,7 @@ class TestSyncer < TuneMyGcTestCase
|
|
116
116
|
snapshots = TuneMyGc::Snapshotter.new
|
117
117
|
snapshots.take_raw(Fixtures::STAGE_BOOTED)
|
118
118
|
stub_request(:post, "https://tunemygc.com/ruby").
|
119
|
-
with(:body => "[#{ActiveSupport::JSON.encode(
|
119
|
+
with(:body => "[#{ActiveSupport::JSON.encode(syncer.environment(snapshots))},[1420152606.1162581,\"BOOTED\",[32,950,1519,569,385225,2014,0,101119,950,0,2184137,1798912,9665288,16777216,26,6,5145,6032,230164,301030,11715304,24159190],{\"major_by\":null,\"gc_by\":\"newobj\",\"have_finalizer\":false,\"immediate_sweep\":false},null]]",
|
120
120
|
:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/json', 'User-Agent'=>"TuneMyGC #{TuneMyGc::VERSION}"}).
|
121
121
|
to_return(:status => 426, :body => "2", :headers => {})
|
122
122
|
|
@@ -133,7 +133,7 @@ class TestSyncer < TuneMyGcTestCase
|
|
133
133
|
snapshots = TuneMyGc::Snapshotter.new
|
134
134
|
snapshots.take_raw(Fixtures::STAGE_BOOTED)
|
135
135
|
stub_request(:post, "https://tunemygc.com/ruby").
|
136
|
-
with(:body => "[#{ActiveSupport::JSON.encode(
|
136
|
+
with(:body => "[#{ActiveSupport::JSON.encode(syncer.environment(snapshots))},[1420152606.1162581,\"BOOTED\",[32,950,1519,569,385225,2014,0,101119,950,0,2184137,1798912,9665288,16777216,26,6,5145,6032,230164,301030,11715304,24159190],{\"major_by\":null,\"gc_by\":\"newobj\",\"have_finalizer\":false,\"immediate_sweep\":false},null]]",
|
137
137
|
:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/json', 'User-Agent'=>"TuneMyGC #{TuneMyGc::VERSION}"}).to_raise(IOError.new("dang"))
|
138
138
|
|
139
139
|
out, err = capture_io do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tunemygc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bear Metal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|