tunemygc 1.0.21 → 1.0.22

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0835ea9c7b907e38b0d816dd64d73cdea16215c0
4
- data.tar.gz: 426c1f8515ba83dd3c021beb85ade70346f71ccc
3
+ metadata.gz: 9672bbb45047e92d9539dc1cb38852dfbb0e2cc6
4
+ data.tar.gz: 1d3f3d06a6c128a0d982ede89904f237d78610f4
5
5
  SHA512:
6
- metadata.gz: d910a5911e19f611c4c6331d546019527d2ecb5987dcc91b644c00d55a21e1b915c71ce4fb47378d37067719e8f380e2e8bb25ed963e23663c0a4de509c9445b
7
- data.tar.gz: f32c86c4b5303ecd93a32256d210ef5afd8d30b019c7d7c8fcfe82e2090fa0a9d479a203abbe73c11133f4aa5111fc1892ef4b9b1739e7cdb7b3d4faba4a8688
6
+ metadata.gz: 66ef450dba0017bf54915abda65be2fbbba8729f1fb096df36bea2d4bf30d50532d64d04f3db3c42bf3629378186fc2a6b649893d0e77a8f8ee0e1971ac127b3
7
+ data.tar.gz: e631316dc487e2dd4d7ca190ccd33c062f1e614305abc8c854d3093f5a4b28e3230b96d012e9d5a975c4842366bcadfe966f5f01a496be054e39fd1c49669c11
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/bear-metal/tunemygc.svg)](https://travis-ci.org/bear-metal/tunemygc)
4
4
 
5
- The Ruby garbage collector has been flagged as the crux of Ruby performance and memory use for a long time. It has improved a lot over the last years, but there's still a lot to tune and control. *The default configuration is not suitable and optimal for Rails applications, and neither is there a one-size-fits-all set of tuned parameters that would suit every app.* However, hand-tuning the GC parameters is a slippery slope to navigate for most developers.
5
+ The Ruby garbage collector has been flagged as the crux of Ruby performance and memory use for a long time. It has improved a lot over the last years, but there's still a lot to tune and control. *The default configuration is not suitable and optimal for large Ruby applications, and neither is there a one-size-fits-all set of tuned parameters that would suit every app.* However, hand-tuning the GC parameters is a slippery slope to navigate for most developers.
6
6
 
7
7
  ## We're fixing this
8
8
 
@@ -33,11 +33,7 @@ Add to your Gemfile and run `bundle install`
33
33
  ``` sh
34
34
  gem 'tunemygc'
35
35
  ```
36
- This gem linterposes itself into the Rails request/response lifecycles and piggy backs off the new GC events in Ruby 2.x for introspection. Tuning recommendations are handled through a web service at `https://tunemygc.com`. You will need a `rails > 4.1`, installation and MRI Ruby `2.1`, or later.
37
-
38
- #### Windows
39
-
40
- Has not been tested at all.
36
+ This gem linterposes itself into the application and piggy backs off the new GC events in Ruby 2.x for introspection. Tuning recommendations are handled through a web service at `https://tunemygc.com`. You will need MRI Ruby `2.1`, or later. [Rails](http://www.rubyonrails.org) applications, background jobs, tests and any proprietary Ruby scripts and frameworks are supported.
41
37
 
42
38
  ## Getting started
43
39
 
@@ -50,7 +46,7 @@ Application registered. Use RUBY_GC_TOKEN=08de9e8822c847244b31290cedfc1d51 in yo
50
46
 
51
47
  We require a valid email address as a canonical reference for tuner tokens for your applications.
52
48
 
53
- For the above command sequences, to sample your Rails app for tuning, run:
49
+ For the above command sequences, to sample your app or script for tuning, run (inject `RUBY_GC_TOKEN` and `RUBY_GC_TUNE` to your env):
54
50
 
55
51
  ``` sh
56
52
  RUBY_GC_TOKEN=08de9e8822c847244b31290cedfc1d51 RUBY_GC_TUNE=1 bundle exec rails s
@@ -61,8 +57,8 @@ The CLI interface supports retrieving configuration options for your application
61
57
  ``` sh
62
58
  $ bundle exec tunemygc
63
59
  Usage: tunemygc [options]
64
- -r, --register EMAIL Register this Rails app with the https://tunemygc.com service
65
- -c, --config TOKEN Fetch the last known config for a given Rails app
60
+ -r, --register EMAIL Register this application with the https://tunemygc.com service
61
+ -c, --config TOKEN Fetch the last known config for a given application
66
62
  -h, --help How to use the TuneMyGC agent CLI
67
63
  ```
68
64
 
@@ -93,9 +89,9 @@ RUBY_GC_TOKEN=08de9e8822c847244b31290cedfc1d51 RUBY_GC_TUNE=1 bundle exec rails
93
89
 
94
90
  #### Advanced
95
91
 
96
- * `RUBY_GC_SPY=action_controller` (Spy on the GC for this type of processing. `action_controller`, `active_job` or `minitest` are supported)
92
+ * `RUBY_GC_SPY=action_controller` (Spy on the GC for this type of processing. `action_controller`, `active_job`, `minitest` or `rspec` are supported)
97
93
 
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.
94
+ 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), [minitest](https://github.com/seattlerb/minitest) and [rspec](http://rspec.info) are also supported as experimental features.
99
95
 
100
96
  * `RUBY_GC_TUNE_REQUESTS=x` (a numeric value eg. `200`)
101
97
 
@@ -107,7 +103,7 @@ Controls the interposer lifetime for sampling ActiveJob jobs. It will enable its
107
103
 
108
104
  * `RUBY_GC_TUNE_TESTS=x` (a numeric value eg. `200`)
109
105
 
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.
106
+ Controls the interposer lifetime for sampling a [minitest](https://github.com/seattlerb/minitest) or [rspec](http://rspec.info) 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.
111
107
 
112
108
  ## How do I use this?
113
109
 
data/lib/tunemygc.rb CHANGED
@@ -11,6 +11,10 @@ module TuneMyGc
11
11
  def self.rails?
12
12
  defined?(Rails) && Rails.version >= "4.0"
13
13
  end
14
+
15
+ def self.rails_version
16
+ rails? ? Rails.version : "0.0"
17
+ end
14
18
  end
15
19
 
16
20
  if ENV["RUBY_GC_TUNE"]
@@ -35,10 +35,6 @@ module TuneMyGc
35
35
  logger.info "[TuneMyGC] #{message}"
36
36
  end
37
37
 
38
- def rails_version
39
- rails? ? Rails.version : "0.0"
40
- end
41
-
42
38
  def spy
43
39
  TuneMyGc::Spies.current
44
40
  end
data/lib/tunemygc/cli.rb CHANGED
@@ -13,10 +13,10 @@ module TuneMyGc
13
13
  OptionParser.new do |opts|
14
14
  opts.banner = "Usage: tunemygc [options]"
15
15
 
16
- opts.on("-r ", "--register EMAIL", "Register this Rails app with the https://tunemygc.com service") do |email|
16
+ opts.on("-r ", "--register EMAIL", "Register this application with the https://tunemygc.com service") do |email|
17
17
  options[:email] = email
18
18
  end
19
- opts.on("-c ", "--config TOKEN", "Fetch the last known config for a given Rails app") do |token|
19
+ opts.on("-c ", "--config TOKEN", "Fetch the last known config for a given application") do |token|
20
20
  options[:config] = token
21
21
  end
22
22
  opts.on_tail("-h", "--help", "How to use the TuneMyGC agent CLI") do
@@ -11,6 +11,7 @@ module TuneMyGc
11
11
  spy :Minitest
12
12
  spy :ActiveJob
13
13
  spy :Manual
14
+ spy :Rspec
14
15
 
15
16
  def self.current
16
17
  s = if ENV['RUBY_GC_SPY']
@@ -0,0 +1,59 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rspec'
4
+
5
+ module TuneMyGc
6
+ module Spies
7
+ class Rspec
8
+ def initialize
9
+ @tests_processed = 0
10
+ @tests_limit = nil
11
+ end
12
+
13
+ def install
14
+ RSpec::Core.__send__(:include, hooks_module)
15
+ TuneMyGc.log "hooked: rspec"
16
+ end
17
+
18
+ def uninstall
19
+ TuneMyGc.uninstall_gc_tracepoint
20
+ TuneMyGc.log "uninstalled GC tracepoint"
21
+ RSpec::Core.__send__(:include, disabled_hooks_module)
22
+ TuneMyGc.log "uninstalled rspec spy"
23
+ end
24
+
25
+ def check_uninstall
26
+ if ENV["RUBY_GC_TUNE_TESTS"]
27
+ @tests_limit ||= Integer(ENV["RUBY_GC_TUNE_TESTS"])
28
+ @tests_processed += 1
29
+ if @tests_processed == @tests_limit
30
+ uninstall
31
+ TuneMyGc.log "kamikaze after #{@tests_processed} of #{@tests_limit} tests"
32
+ end
33
+ end
34
+ end
35
+
36
+ def hooks_module
37
+ Module.new do
38
+ RSpec.configure do |c|
39
+ c.before(:all) { TuneMyGc.processing_started }
40
+ c.after(:all) { TuneMyGc.processing_ended }
41
+ end
42
+ end
43
+ end
44
+
45
+ def disabled_hooks_module
46
+ Module.new do
47
+ private
48
+ def tunemygc_before_setup
49
+ # noop
50
+ end
51
+
52
+ def tunemygc_after_teardown
53
+ # noop
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module TuneMyGc
4
- VERSION = "1.0.21"
4
+ VERSION = "1.0.22"
5
5
  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.21
4
+ version: 1.0.22
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-19 00:00:00.000000000 Z
11
+ date: 2015-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -149,6 +149,7 @@ files:
149
149
  - lib/tunemygc/spies/active_job.rb
150
150
  - lib/tunemygc/spies/manual.rb
151
151
  - lib/tunemygc/spies/minitest.rb
152
+ - lib/tunemygc/spies/rspec.rb
152
153
  - lib/tunemygc/subscriber.rb
153
154
  - lib/tunemygc/syncer.rb
154
155
  - lib/tunemygc/version.rb