garbageman 0.1.14 → 0.1.15
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/VERSION +1 -1
- data/garbageman.gemspec +2 -2
- data/lib/garbageman/collector.rb +21 -3
- data/lib/garbageman/config.rb +2 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.15
|
data/garbageman.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "garbageman"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.15"
|
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"]
|
12
|
-
s.date = "2013-06-
|
12
|
+
s.date = "2013-06-19"
|
13
13
|
s.description = "Disable GC while processing requests. By using nginx upstream health checks to garbage collect when no one is there."
|
14
14
|
s.email = "doug@sessionm.com"
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/garbageman/collector.rb
CHANGED
@@ -14,7 +14,7 @@ module GarbageMan
|
|
14
14
|
include Status
|
15
15
|
|
16
16
|
attr_accessor :request_count, :will_collect, :will_select_next_server, :show_gc_times
|
17
|
-
attr_reader :fiber_poll
|
17
|
+
attr_reader :fiber_poll, :last_gc_finished_at
|
18
18
|
|
19
19
|
def initialize
|
20
20
|
@show_gc_times = true
|
@@ -66,7 +66,8 @@ module GarbageMan
|
|
66
66
|
starts = Time.now
|
67
67
|
GC.enable
|
68
68
|
GC.start
|
69
|
-
|
69
|
+
@last_gc_finished_at = Time.now
|
70
|
+
diff = (@last_gc_finished_at - starts) * 1000
|
70
71
|
info "GC took #{'%.2f' % diff}ms for #{@request_count} requests" if @show_gc_times
|
71
72
|
write_gc_yaml server_index, NEXT_SERVER
|
72
73
|
|
@@ -174,8 +175,16 @@ module GarbageMan
|
|
174
175
|
! forcing_gc?
|
175
176
|
end
|
176
177
|
|
178
|
+
def uses_sockets?
|
179
|
+
Config.thin_config.has_key?('socket')
|
180
|
+
end
|
181
|
+
|
177
182
|
def can_disable?
|
178
|
-
|
183
|
+
uses_sockets? &&
|
184
|
+
not_queuing? &&
|
185
|
+
have_not_waited_too_long_to_gc? &&
|
186
|
+
not_forcing_gc? &&
|
187
|
+
enough_running_servers?
|
179
188
|
end
|
180
189
|
|
181
190
|
def num_running_servers
|
@@ -194,6 +203,15 @@ module GarbageMan
|
|
194
203
|
def socket_file(index)
|
195
204
|
Config.thin_config['socket'].sub '.sock', ".#{index}.sock"
|
196
205
|
end
|
206
|
+
|
207
|
+
def waited_too_long_to_gc?
|
208
|
+
return false unless @last_gc_finished_at
|
209
|
+
(Time.now - @last_gc_finished_at) >= Config.max_time_without_gc
|
210
|
+
end
|
211
|
+
|
212
|
+
def have_not_waited_too_long_to_gc?
|
213
|
+
! waited_too_long_to_gc?
|
214
|
+
end
|
197
215
|
end
|
198
216
|
end
|
199
217
|
|
data/lib/garbageman/config.rb
CHANGED
@@ -25,5 +25,7 @@ module GarbageMan
|
|
25
25
|
# absolutely make sure we are in the pool again before selecting next server
|
26
26
|
def self.num_request_before_selecting_next_server; 10; end
|
27
27
|
def self.min_servers_to_disable_gc; 2; end
|
28
|
+
# if we have not GC in 20 seconds turn back on GC
|
29
|
+
def self.max_time_without_gc; 20; end
|
28
30
|
end
|
29
31
|
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.
|
4
|
+
version: 0.1.15
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rdoc
|
@@ -102,7 +102,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
102
|
version: '0'
|
103
103
|
segments:
|
104
104
|
- 0
|
105
|
-
hash:
|
105
|
+
hash: -2750624905344639858
|
106
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
107
|
none: false
|
108
108
|
requirements:
|