tunemygc 1.0.2 → 1.0.3

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: 9fbad2da645aa2d033f78de306ebd504cca2c5ca
4
- data.tar.gz: c7ece64385753be5dcd120103c952b40213eb907
3
+ metadata.gz: 41abc48ffc1562a193e97168a0facaa7666be2f1
4
+ data.tar.gz: d1c8a2926de499ec7570b39fa488658ed25ea937
5
5
  SHA512:
6
- metadata.gz: 4a3a8bdcdae61551a2342fb4142434c2e1c0883a92667d26c4da71342d7b1a73ff9807ccfb8d274b2a7abad4cb4b52b071062ffbe0e5bc29500499d55e4a1fa5
7
- data.tar.gz: d0cf1b7bbfee6f1bb9deba037a4ec61e57ca9eb9298664277ba76a6eb3cdf586c727662b02651d56c7b76090a17a856a86f9f9979b0d312c31f2cca61339b62d
6
+ metadata.gz: 0f5e541a864122230c090f8c33a1f8f08db17ee376f2f4cda23af1c67c7e3c529f16ed5d9337731299bc8261f88e4ce1cce1e5d5d832676eeeecaae805364215
7
+ data.tar.gz: 85c5077715cd14909ea3bec3e111767580f9c4804706719010a8ce2455984956531e33652aa4d4e3eaa36cc5c5439e7d37b0788a9381ea292f169b3b134219bd
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  .DS_Store
2
2
  .ruby-version
3
3
  tmp/*
4
- lib/tunemygc/tunemygc_ext.*
4
+ lib/tunemygc/tunemygc_ext.*
5
+ *.gem
@@ -8,7 +8,7 @@ rvm:
8
8
  - 2.2.0
9
9
  - ruby-head
10
10
  script: "bundle exec rake"
11
- env: RUBY_GC_TUNE=1 RUBY_GC_TUNE_DEBUG=1
11
+ env: RUBY_GC_TUNE=1 RUBY_GC_TUNE_DEBUG=1 RUBY_GC_SYNC_ALWAYS=1
12
12
  gemfile:
13
13
  - Gemfile
14
14
  notifications:
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tunemygc (1.0.1)
4
+ tunemygc (1.0.2)
5
5
  activesupport (~> 4.1)
6
6
  certified (~> 1.0, >= 1.0.0)
7
7
 
@@ -4,12 +4,15 @@ require 'thread'
4
4
 
5
5
  module TuneMyGc
6
6
  class Snapshotter
7
+ UNITS_OF_WORK = /REQUEST_PROCESSING_STARTED|REQUEST_PROCESSING_ENDED/
7
8
  MAX_SAMPLES = 1000
8
9
 
9
10
  attr_reader :buffer
11
+ attr_accessor :unit_of_work
10
12
 
11
13
  def initialize(buf = Queue.new)
12
14
  @buffer = buf
15
+ @unit_of_work = false
13
16
  end
14
17
 
15
18
  def take(stage, timestamp = nil, meta = nil)
@@ -40,6 +43,7 @@ module TuneMyGc
40
43
  private
41
44
  def _buffer(snapshot)
42
45
  if size < MAX_SAMPLES
46
+ self.unit_of_work = true if snapshot[3] =~ UNITS_OF_WORK
43
47
  @buffer << snapshot
44
48
  else
45
49
  TuneMyGc.log "Discarding snapshot #{snapshot.inspect} (max samples threshold of #{MAX_SAMPLES} reached)"
@@ -19,13 +19,23 @@ module TuneMyGc
19
19
  end
20
20
 
21
21
  def sync(snapshotter)
22
- response = nil
23
- timeout do
24
- response = sync_with_tuner(snapshotter)
22
+ if sync_required?(snapshotter)
23
+ response = nil
24
+ timeout do
25
+ response = sync_with_tuner(snapshotter)
26
+ end
27
+ timeout do
28
+ process_config_callback(response)
29
+ end if response
30
+ else
31
+ TuneMyGc.log "Nothing to sync, discarding #{snapshotter.size} snapshots"
32
+ snapshotter.clear
25
33
  end
26
- timeout do
27
- process_config_callback(response)
28
- end if response
34
+ end
35
+
36
+ def sync_required?(snapshotter)
37
+ return true if ENV['RUBY_GC_SYNC_ALWAYS']
38
+ snapshotter.unit_of_work
29
39
  end
30
40
 
31
41
  private
@@ -48,6 +58,7 @@ module TuneMyGc
48
58
  end
49
59
  data = ActiveSupport::JSON.encode(payload)
50
60
  response = client.post(uri.path, data, TuneMyGc::HEADERS)
61
+ snapshotter.unit_of_work = false
51
62
  if Net::HTTPNotFound === response
52
63
  TuneMyGc.log "Invalid application token. Please generate one with 'bundle exec tunemygc <a_valid_email_address>' and set the RUBY_GC_TOKEN environment variable"
53
64
  return false
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module TuneMyGc
4
- VERSION = "1.0.2"
4
+ VERSION = "1.0.3"
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.2
4
+ version: 1.0.3
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-01-29 00:00:00.000000000 Z
11
+ date: 2015-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -140,7 +140,6 @@ files:
140
140
  - test/test_railtie.rb
141
141
  - test/test_snapshotter.rb
142
142
  - test/test_syncer.rb
143
- - tunemygc-1.0.gem
144
143
  - tunemygc.gemspec
145
144
  homepage: https://tunemygc.com
146
145
  licenses:
Binary file