garbageman 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = garbageman
2
2
 
3
- Description goes here.
3
+ Rubies GC can take a long time. And while ruby is garbage collecting nothing else can happen. This is especially bad in an async environment like EventMachine where it is a single thread process. The GarbageMan disable rubies GC while processing requests. And while it is GCing it takes it self out of the nginx upstream.
4
4
 
5
5
  == Contributing to garbageman
6
6
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
data/garbageman.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "garbageman"
8
- s.version = "0.1.5"
8
+ s.version = "0.1.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Doug Youch"]
@@ -4,6 +4,15 @@ module GarbageMan
4
4
  class Collector
5
5
  include Singleton
6
6
 
7
+ module Status
8
+ SELECTED = 'selected'
9
+ WILL_COLLECT = 'will_collect'
10
+ STARTING = 'starting'
11
+ NEXT_SERVER = 'next_server'
12
+ end
13
+
14
+ include Status
15
+
7
16
  attr_accessor :request_count, :will_collect
8
17
  attr_reader :fiber_poll
9
18
 
@@ -23,8 +32,15 @@ module GarbageMan
23
32
  return true
24
33
  end
25
34
 
35
+ if select_next_server?
36
+ EM.next_tick do
37
+ select_next_server
38
+ end
39
+ return true
40
+ end
41
+
26
42
  if should_collect?
27
- write_gc_yaml server_index, 'will_collect'
43
+ write_gc_yaml server_index, WILL_COLLECT
28
44
  false
29
45
  else
30
46
  true
@@ -41,18 +57,18 @@ module GarbageMan
41
57
 
42
58
  return unless can_collect?
43
59
 
44
- write_gc_yaml server_index, 'starting'
60
+ write_gc_yaml server_index, STARTING
45
61
  debug "starting gc"
46
62
  starts = Time.now
47
63
  GC.enable
48
64
  GC.start
49
65
  diff = (Time.now - starts) * 1000
50
66
  info "GC took #{'%.2f' % diff}ms"
51
- write_gc_yaml server_index, 'finished'
67
+ write_gc_yaml server_index, NEXT_SERVER
52
68
 
53
69
  reset
54
70
 
55
- if can_disable? && select_next_server
71
+ if can_disable?
56
72
  debug "disabling gc"
57
73
  GC.disable
58
74
  else
@@ -64,7 +80,7 @@ module GarbageMan
64
80
  def create_gc_yaml
65
81
  return unless server_index
66
82
  return if File.exists?(Config.gc_yaml_file)
67
- write_gc_yaml server_index, 'selected'
83
+ write_gc_yaml server_index, SELECTED
68
84
  end
69
85
 
70
86
  def logger; GarbageMan.logger; end
@@ -98,7 +114,7 @@ module GarbageMan
98
114
  file = socket_file next_server_index
99
115
  next unless File.exists?(file)
100
116
  debug "selected #{next_server_index}"
101
- write_gc_yaml next_server_index, 'selected'
117
+ write_gc_yaml next_server_index, SELECTED
102
118
  return true
103
119
  end
104
120
  false
@@ -136,6 +152,11 @@ module GarbageMan
136
152
  config && config['gc'] && config['gc']['server'] && config['gc']['server'] == server_index
137
153
  end
138
154
 
155
+ def select_next_server?
156
+ config = Config.gc_config
157
+ config && config['gc'] && config['gc']['server'] && config['gc']['server'] == server_index && config['gc']['status'] == 'next_server'
158
+ end
159
+
139
160
  def can_disable?
140
161
  Config.thin_config.has_key?('socket') && not_queuing? && min_running_servers?
141
162
  end
@@ -19,6 +19,6 @@ module GarbageMan
19
19
  def self.thin_config; @@thin_config ||= YAML.load_file("./config/thin.yml"); end
20
20
 
21
21
  def self.num_request_before_collecting; 10; end
22
- def self.min_servers_to_disable_gc; 3; end
22
+ def self.min_servers_to_disable_gc; 2; end
23
23
  end
24
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: garbageman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -102,7 +102,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
102
  version: '0'
103
103
  segments:
104
104
  - 0
105
- hash: -4485848182295585686
105
+ hash: 244992225797517962
106
106
  required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  none: false
108
108
  requirements: