tunemygc 1.0.12 → 1.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -1
- data/README.md +6 -2
- data/lib/tunemygc/spies.rb +1 -0
- data/lib/tunemygc/spies/action_controller.rb +18 -5
- data/lib/tunemygc/spies/active_job.rb +70 -0
- data/lib/tunemygc/version.rb +1 -1
- data/test/helper.rb +0 -20
- data/test/test_action_controller_interposer.rb +5 -0
- data/test/test_activejob_interposer.rb +89 -0
- data/test/test_minitest_interposer.rb +14 -0
- data/tunemygc.gemspec +3 -2
- metadata +21 -5
- data/lib/tunemygc/request_subscriber.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3f306241edb410736b2b01067f4904c2b49f91b
|
4
|
+
data.tar.gz: a8bc6b26e270e9dae4a864a24828d6f7352864ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e58c2e51304db18732f5ba275d8b599b6c5b6cc703e9caef7e739fdea01bfadf08bae0d7b034943a5ba6475f527ee3e27ef40579250b995be0a0a795092093f
|
7
|
+
data.tar.gz: 0bd6ccde3394c560038b1e7612ede7a8e9081cc657796523dd5dbedcfba47ad356aff16404b557406b11fd3f2a6fd0aabe82b86a557549348a43ec00672d507a
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
tunemygc (1.0.
|
4
|
+
tunemygc (1.0.12)
|
5
5
|
activesupport (~> 4.1)
|
6
6
|
certified (~> 1.0, >= 1.0.0)
|
7
7
|
|
@@ -118,6 +118,7 @@ PLATFORMS
|
|
118
118
|
ruby
|
119
119
|
|
120
120
|
DEPENDENCIES
|
121
|
+
activejob (~> 4.2.0)
|
121
122
|
rails
|
122
123
|
rake (~> 10.3)
|
123
124
|
rake-compiler (~> 0.9, >= 0.9.5)
|
data/README.md
CHANGED
@@ -93,14 +93,18 @@ RUBY_GC_TOKEN=08de9e8822c847244b31290cedfc1d51 RUBY_GC_TUNE=1 bundle exec rails
|
|
93
93
|
|
94
94
|
#### Advanced
|
95
95
|
|
96
|
-
* `RUBY_GC_SPY=action_controller` (Spy on the GC for this type of processing.
|
96
|
+
* `RUBY_GC_SPY=action_controller` (Spy on the GC for this type of processing. `action_controller`, `active_job` or `minitest` are supported)
|
97
97
|
|
98
|
-
Defines what type of processing you would like to sample for GC activity. An Action Controller spy is the default, but [minitest](https://github.com/seattlerb/minitest)
|
98
|
+
Defines what type of processing you would like to sample for GC activity. An Action Controller spy is the default, but [ActiveJob](https://github.com/rails/rails/tree/master/activejob) and [minitest](https://github.com/seattlerb/minitest) are also supported as experimental features.
|
99
99
|
|
100
100
|
* `RUBY_GC_TUNE_REQUESTS=x` (a numeric value eg. `200`)
|
101
101
|
|
102
102
|
Controls the interposer lifetime for sampling Rails requests. It will enable itself, then remove request instrumentation after the specified number of requests. A good minimum ballpark sample set would be 200.
|
103
103
|
|
104
|
+
* `RUBY_GC_TUNE_JOBS=x` (a numeric value eg. `200`)
|
105
|
+
|
106
|
+
Controls the interposer lifetime for sampling ActiveJob jobs. It will enable itself, then remove job instrumentation after the specified number of jobs were processed. A good minimum ballpark sample set would be 200.
|
107
|
+
|
104
108
|
* `RUBY_GC_TUNE_TESTS=x` (a numeric value eg. `200`)
|
105
109
|
|
106
110
|
Controls the interposer lifetime for sampling a [minitest](https://github.com/seattlerb/minitest) based test suite. It will enable itself, then remove request instrumentation after the specified number of tests has been run. A good minimum ballpark sample set would be 200.
|
data/lib/tunemygc/spies.rb
CHANGED
@@ -1,6 +1,21 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require 'tunemygc/
|
3
|
+
require 'tunemygc/subscriber'
|
4
|
+
|
5
|
+
module TuneMyGc
|
6
|
+
class StartRequestSubscriber < Subscriber
|
7
|
+
def start(name, id, payload)
|
8
|
+
TuneMyGc.snapshot(:PROCESSING_STARTED)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class EndRequestSubscriber < Subscriber
|
13
|
+
def finish(name, id, payload)
|
14
|
+
TuneMyGc.snapshot(:PROCESSING_ENDED)
|
15
|
+
TuneMyGc.interposer.check_uninstall
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
4
19
|
|
5
20
|
module TuneMyGc
|
6
21
|
module Spies
|
@@ -15,10 +30,8 @@ module TuneMyGc
|
|
15
30
|
|
16
31
|
def install
|
17
32
|
@subscriptions << ActiveSupport::Notifications.subscribe(/^start_processing.action_controller$/, TuneMyGc::StartRequestSubscriber.new)
|
18
|
-
TuneMyGc.log "hooked: start_processing.action_controller"
|
19
|
-
|
20
33
|
@subscriptions << ActiveSupport::Notifications.subscribe(/^process_action.action_controller$/, TuneMyGc::EndRequestSubscriber.new)
|
21
|
-
TuneMyGc.log "hooked:
|
34
|
+
TuneMyGc.log "hooked: action_controller"
|
22
35
|
end
|
23
36
|
|
24
37
|
def uninstall
|
@@ -26,7 +39,7 @@ module TuneMyGc
|
|
26
39
|
TuneMyGc.log "uninstalled GC tracepoint"
|
27
40
|
@subscriptions.each{|s| ActiveSupport::Notifications.unsubscribe(s) }
|
28
41
|
@subscriptions.clear
|
29
|
-
TuneMyGc.log "
|
42
|
+
TuneMyGc.log "uninstalled action_controller spy"
|
30
43
|
end
|
31
44
|
|
32
45
|
def check_uninstall
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'active_job'
|
4
|
+
|
5
|
+
module TuneMyGc
|
6
|
+
module Spies
|
7
|
+
class ActiveJob
|
8
|
+
def initialize
|
9
|
+
@jobs_processed = 0
|
10
|
+
@jobs_limit = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def install
|
14
|
+
::ActiveJob::Base.__send__(:include, hooks_module)
|
15
|
+
TuneMyGc.log "hooked: active_job"
|
16
|
+
end
|
17
|
+
|
18
|
+
def uninstall
|
19
|
+
TuneMyGc.uninstall_gc_tracepoint
|
20
|
+
TuneMyGc.log "uninstalled GC tracepoint"
|
21
|
+
::ActiveJob::Base.__send__(:include, disabled_hooks_module)
|
22
|
+
TuneMyGc.log "uninstalled active_job spy"
|
23
|
+
end
|
24
|
+
|
25
|
+
def check_uninstall
|
26
|
+
if ENV["RUBY_GC_TUNE_JOBS"]
|
27
|
+
@jobs_limit ||= Integer(ENV["RUBY_GC_TUNE_JOBS"])
|
28
|
+
@jobs_processed += 1
|
29
|
+
if @jobs_processed == @jobs_limit
|
30
|
+
uninstall
|
31
|
+
TuneMyGc.log "kamikaze after #{@jobs_processed} of #{@jobs_limit} jobs"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def hooks_module
|
37
|
+
Module.new do
|
38
|
+
def self.included(base)
|
39
|
+
base.around_perform :tunemygc_perform_job
|
40
|
+
end
|
41
|
+
|
42
|
+
def tunemygc_perform_job(*args)
|
43
|
+
tunemygc_before_perform
|
44
|
+
yield
|
45
|
+
tunemygc_after_perform
|
46
|
+
end
|
47
|
+
|
48
|
+
def tunemygc_before_perform
|
49
|
+
TuneMyGc.snapshot(:PROCESSING_STARTED)
|
50
|
+
end
|
51
|
+
|
52
|
+
def tunemygc_after_perform
|
53
|
+
TuneMyGc.snapshot(:PROCESSING_ENDED)
|
54
|
+
TuneMyGc.interposer.check_uninstall
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def disabled_hooks_module
|
60
|
+
Module.new do
|
61
|
+
def tunemygc_before_perform
|
62
|
+
end
|
63
|
+
|
64
|
+
def tunemygc_after_perform
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/lib/tunemygc/version.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -22,24 +22,4 @@ class TuneMyGcTestCase < Minitest::Test
|
|
22
22
|
GC.stress = false
|
23
23
|
end
|
24
24
|
end
|
25
|
-
|
26
|
-
def process_tunemygc_request(path = '/test')
|
27
|
-
ActiveSupport::Notifications.instrument('start_processing.action_controller', path: path) {}
|
28
|
-
ActiveSupport::Notifications.instrument('process_action.action_controller', path: path) {}
|
29
|
-
end
|
30
|
-
|
31
|
-
def run_tunemygc_test
|
32
|
-
MinitestSandboxTest.new("test_minitest_spy").run
|
33
|
-
end
|
34
25
|
end
|
35
|
-
|
36
|
-
# for Minitest spy
|
37
|
-
class MinitestSandboxTest < MiniTest::Unit::TestCase
|
38
|
-
def setup
|
39
|
-
@value = 123
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_minitest_spy
|
43
|
-
assert_equal 123, @value
|
44
|
-
end
|
45
|
-
end
|
@@ -77,4 +77,9 @@ class TestActionControllerInterposer < TuneMyGcTestCase
|
|
77
77
|
ensure
|
78
78
|
ENV.delete("RUBY_GC_TUNE_REQUESTS")
|
79
79
|
end
|
80
|
+
|
81
|
+
def process_tunemygc_request(path = '/test')
|
82
|
+
ActiveSupport::Notifications.instrument('start_processing.action_controller', path: path) {}
|
83
|
+
ActiveSupport::Notifications.instrument('process_action.action_controller', path: path) {}
|
84
|
+
end
|
80
85
|
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), 'helper')
|
4
|
+
require 'active_job'
|
5
|
+
|
6
|
+
class TuneMyGcJob < ActiveJob::Base
|
7
|
+
def perform
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class TestActiveJobInterposer < TuneMyGcTestCase
|
12
|
+
def setup
|
13
|
+
TuneMyGc.interposer.uninstall
|
14
|
+
end
|
15
|
+
|
16
|
+
def teardown
|
17
|
+
TuneMyGc.interposer = TuneMyGc::Interposer.new(:ActionController)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_init
|
21
|
+
TuneMyGc.interposer = TuneMyGc::Interposer.new(:ActiveJob)
|
22
|
+
interposer = TuneMyGc.interposer
|
23
|
+
assert !interposer.installed
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_install_uninstall
|
27
|
+
TuneMyGc.interposer = TuneMyGc::Interposer.new(:ActiveJob)
|
28
|
+
interposer = TuneMyGc.interposer
|
29
|
+
interposer.install
|
30
|
+
interposer.on_initialized
|
31
|
+
assert interposer.installed
|
32
|
+
assert_nil interposer.install
|
33
|
+
|
34
|
+
interposer.uninstall
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_gc_hooks
|
38
|
+
TuneMyGc.interposer = TuneMyGc::Interposer.new(:ActiveJob)
|
39
|
+
interposer = TuneMyGc.interposer
|
40
|
+
interposer.install
|
41
|
+
TuneMyGc.interposer.on_initialized
|
42
|
+
|
43
|
+
GC.start(full_mark: true, immediate_sweep: false)
|
44
|
+
GC.start(full_mark: true, immediate_sweep: true)
|
45
|
+
|
46
|
+
stages = []
|
47
|
+
|
48
|
+
while !TuneMyGc.snapshotter.empty?
|
49
|
+
stages << TuneMyGc.snapshotter.deq
|
50
|
+
end
|
51
|
+
|
52
|
+
# Account for incremental GC on 2.2
|
53
|
+
cycles = [:GC_CYCLE_STARTED, :GC_CYCLE_ENTERED]
|
54
|
+
|
55
|
+
assert stages.any?{|s| cycles.include?(s[3]) }
|
56
|
+
|
57
|
+
interposer.uninstall
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_tests_limit
|
61
|
+
TuneMyGc.interposer = TuneMyGc::Interposer.new(:ActiveJob)
|
62
|
+
interposer = TuneMyGc.interposer
|
63
|
+
interposer.install
|
64
|
+
TuneMyGc.interposer.on_initialized
|
65
|
+
|
66
|
+
ENV["RUBY_GC_TUNE_JOBS"] = "2"
|
67
|
+
|
68
|
+
run_tunemygc_job
|
69
|
+
run_tunemygc_job
|
70
|
+
|
71
|
+
stages = []
|
72
|
+
|
73
|
+
while !TuneMyGc.snapshotter.empty?
|
74
|
+
stages << TuneMyGc.snapshotter.deq
|
75
|
+
end
|
76
|
+
|
77
|
+
cycles = [:PROCESSING_STARTED]
|
78
|
+
|
79
|
+
assert stages.any?{|s| cycles.include?(s[3]) }
|
80
|
+
|
81
|
+
interposer.uninstall
|
82
|
+
ensure
|
83
|
+
ENV.delete("RUBY_GC_TUNE_TESTS")
|
84
|
+
end
|
85
|
+
|
86
|
+
def run_tunemygc_job
|
87
|
+
TuneMyGcJob.new.perform_now
|
88
|
+
end
|
89
|
+
end
|
@@ -2,6 +2,16 @@
|
|
2
2
|
|
3
3
|
require File.join(File.dirname(__FILE__), 'helper')
|
4
4
|
|
5
|
+
class MinitestSandboxTest < MiniTest::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
@value = 123
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_minitest_spy
|
11
|
+
assert_equal 123, @value
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
5
15
|
class TestMinitestInterposer < TuneMyGcTestCase
|
6
16
|
def setup
|
7
17
|
TuneMyGc.interposer.uninstall
|
@@ -76,4 +86,8 @@ class TestMinitestInterposer < TuneMyGcTestCase
|
|
76
86
|
ensure
|
77
87
|
ENV.delete("RUBY_GC_TUNE_TESTS")
|
78
88
|
end
|
89
|
+
|
90
|
+
def run_tunemygc_test
|
91
|
+
MinitestSandboxTest.new("test_minitest_spy").run
|
92
|
+
end
|
79
93
|
end
|
data/tunemygc.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
|
27
27
|
Run this setup command from your application root to register your application with the `https://tunemygc.com` service:
|
28
28
|
|
29
|
-
bundle exec tunemygc -r your@email.address
|
29
|
+
$ bundle exec tunemygc -r your@email.address
|
30
30
|
|
31
31
|
You should get back a token reference to identify this Rails app:
|
32
32
|
|
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
|
35
35
|
Then sample your Rails app for tuning:
|
36
36
|
|
37
|
-
RUBY_GC_TOKEN=08de9e8822c847244b31290cedfc1d32 RUBY_GC_TUNE=1 bundle exec rails s
|
37
|
+
$ RUBY_GC_TOKEN=08de9e8822c847244b31290cedfc1d32 RUBY_GC_TUNE=1 bundle exec rails s
|
38
38
|
|
39
39
|
We require a valid email address as a canonical reference for tuner tokens for your applications.
|
40
40
|
|
@@ -47,4 +47,5 @@ eos
|
|
47
47
|
s.add_development_dependency('rake', '~> 10.3')
|
48
48
|
s.add_development_dependency('rake-compiler', '~> 0.9', '>= 0.9.5')
|
49
49
|
s.add_development_dependency('webmock', '~> 1.2', '>= 1.2.0')
|
50
|
+
s.add_development_dependency('activejob', '~> 4.2.0')
|
50
51
|
end
|
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.13
|
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-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -98,6 +98,20 @@ dependencies:
|
|
98
98
|
- - ">="
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: 1.2.0
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: activejob
|
103
|
+
requirement: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - "~>"
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: 4.2.0
|
108
|
+
type: :development
|
109
|
+
prerelease: false
|
110
|
+
version_requirements: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - "~>"
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: 4.2.0
|
101
115
|
description: Agent for the GC tuning webservice https://www.tunemygc.com - optimal
|
102
116
|
settings for throughput and memory usage of Rails applications
|
103
117
|
email:
|
@@ -127,10 +141,10 @@ files:
|
|
127
141
|
- lib/tunemygc/configurator.rb
|
128
142
|
- lib/tunemygc/interposer.rb
|
129
143
|
- lib/tunemygc/railtie.rb
|
130
|
-
- lib/tunemygc/request_subscriber.rb
|
131
144
|
- lib/tunemygc/snapshotter.rb
|
132
145
|
- lib/tunemygc/spies.rb
|
133
146
|
- lib/tunemygc/spies/action_controller.rb
|
147
|
+
- lib/tunemygc/spies/active_job.rb
|
134
148
|
- lib/tunemygc/spies/minitest.rb
|
135
149
|
- lib/tunemygc/subscriber.rb
|
136
150
|
- lib/tunemygc/syncer.rb
|
@@ -138,6 +152,7 @@ files:
|
|
138
152
|
- test/fixtures.rb
|
139
153
|
- test/helper.rb
|
140
154
|
- test/test_action_controller_interposer.rb
|
155
|
+
- test/test_activejob_interposer.rb
|
141
156
|
- test/test_agent.rb
|
142
157
|
- test/test_minitest_interposer.rb
|
143
158
|
- test/test_railtie.rb
|
@@ -153,7 +168,7 @@ post_install_message: |2
|
|
153
168
|
|
154
169
|
Run this setup command from your application root to register your application with the `https://tunemygc.com` service:
|
155
170
|
|
156
|
-
bundle exec tunemygc -r your@email.address
|
171
|
+
$ bundle exec tunemygc -r your@email.address
|
157
172
|
|
158
173
|
You should get back a token reference to identify this Rails app:
|
159
174
|
|
@@ -161,7 +176,7 @@ post_install_message: |2
|
|
161
176
|
|
162
177
|
Then sample your Rails app for tuning:
|
163
178
|
|
164
|
-
RUBY_GC_TOKEN=08de9e8822c847244b31290cedfc1d32 RUBY_GC_TUNE=1 bundle exec rails s
|
179
|
+
$ RUBY_GC_TOKEN=08de9e8822c847244b31290cedfc1d32 RUBY_GC_TUNE=1 bundle exec rails s
|
165
180
|
|
166
181
|
We require a valid email address as a canonical reference for tuner tokens for your applications.
|
167
182
|
|
@@ -190,6 +205,7 @@ test_files:
|
|
190
205
|
- test/fixtures.rb
|
191
206
|
- test/helper.rb
|
192
207
|
- test/test_action_controller_interposer.rb
|
208
|
+
- test/test_activejob_interposer.rb
|
193
209
|
- test/test_agent.rb
|
194
210
|
- test/test_minitest_interposer.rb
|
195
211
|
- test/test_railtie.rb
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'tunemygc/subscriber'
|
4
|
-
|
5
|
-
module TuneMyGc
|
6
|
-
class StartRequestSubscriber < Subscriber
|
7
|
-
def start(name, id, payload)
|
8
|
-
TuneMyGc.snapshot(:PROCESSING_STARTED)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
class EndRequestSubscriber < Subscriber
|
13
|
-
def finish(name, id, payload)
|
14
|
-
TuneMyGc.snapshot(:PROCESSING_ENDED)
|
15
|
-
TuneMyGc.interposer.check_uninstall
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|