symphony 0.9.2 → 0.10.0.pre20150904120928

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: 53cc6c7bef0985416836fbf99f95500ed4d40de4
4
- data.tar.gz: b8974d95f36961b34c4e50a82bfdef93681fa2d6
3
+ metadata.gz: 5ac532bca93f670d19204728d5d1cd1d1a887b02
4
+ data.tar.gz: 9d1ef778dd4d19414739b855cb242f650e15252f
5
5
  SHA512:
6
- metadata.gz: 7ee965658a4f05bc91447cd0771658e0f0e5875273c24991c558a03aee728ea134941b9ef0d49fb430cfd7aa249523b89cb3785a3187f5b075d1a7b6e0418d7f
7
- data.tar.gz: 7cd25b5d827f48a5dab0607535e9e80b2fe9ea3d7ba75511aa8efff09e8809b658e11a8df31c95f72e6697ac1637fc7eecbaa032b5bbdf614e66ead26981eb3f
6
+ metadata.gz: c592497ebea87cdec1fc14dbb3a854d389fa70d293e148278fca8d7ee9e5e3d8790a3d3b760e30042bff48034f4837c8513b659bf5ccf06645341c51982b4844
7
+ data.tar.gz: e242316c2b893f106a7f1508ea735cade90f42d2fc208f9d11720eba123ad744cb660bbaa3f5060fd31bc8fde1434f06ed518597331686eaf3d01d17437fc983
checksums.yaml.gz.sig CHANGED
Binary file
data/ChangeLog CHANGED
@@ -1,9 +1,30 @@
1
+ 2015-09-03 Michael Granger <ged@FaerieMUD.org>
2
+
3
+ * lib/symphony/statistics.rb, lib/symphony/task_group/longlived.rb,
4
+ spec/symphony/task_group/longlived_spec.rb:
5
+ Invert scaling logic to handle initial load
6
+ [fd66c7ade2b0] [tip]
7
+
8
+ 2015-07-07 Michael Granger <ged@FaerieMUD.org>
9
+
10
+ * .hgtags:
11
+ Added tag v0.9.2 for changeset a802f4bea30c
12
+ [a29e516eb7c7]
13
+
14
+ * .hgsigs:
15
+ Added signature for changeset 4171fb773f62
16
+ [a802f4bea30c] [v0.9.2]
17
+
18
+ * History.rdoc, lib/symphony.rb, symphony.gemspec:
19
+ Bump the patch version, update history.
20
+ [4171fb773f62]
21
+
1
22
  2015-07-07 Mahlon E. Smith <mahlon@martini.nu>
2
23
 
3
24
  * lib/symphony/task.rb:
4
25
  Ensure the work callback's block returns the work() rval, instead of
5
26
  the current time. This fixes Task acknowledgement.
6
- [889ec4c329ed] [tip]
27
+ [889ec4c329ed]
7
28
 
8
29
  2015-06-08 Michael Granger <ged@FaerieMUD.org>
9
30
 
@@ -26,7 +47,7 @@
26
47
  The Daemon will now load them on startup. This is so code that can
27
48
  depend on Symphony without loading every configured task anytime its
28
49
  config loads.
29
- [ade5a2647590]
50
+ [ade5a2647590] [github/master]
30
51
 
31
52
  2015-06-01 Michael Granger <ged@FaerieMUD.org>
32
53
 
@@ -44,7 +65,7 @@
44
65
 
45
66
  * spec/helpers.rb:
46
67
  Add #message_count to the mock queue class
47
- [3dad232548eb] [github/master]
68
+ [3dad232548eb]
48
69
 
49
70
  * lib/symphony/routing.rb, spec/symphony/routing_spec.rb:
50
71
  Fix the patterns used by Symphony::Routing
data/History.rdoc CHANGED
@@ -1,21 +1,3 @@
1
- == v0.9.2 [2015-07-07] Mahlon E. Smith <mahlon@martini.nu>
2
-
3
- Fixes:
4
-
5
- - Ensure the work callback's block returns the work() rval, instead of
6
- the current time. This fixes Task acknowledgement.
7
-
8
-
9
- == v0.9.1 [2015-06-08] Michael Granger <ged@FaerieMUD.org>
10
-
11
- Fixes:
12
-
13
- - Make Symphony.tasks contain just the task names.
14
- The Daemon will now load task classes on startup. This is so code can
15
- depend on Symphony without loading every configured task anytime its
16
- config loads.
17
-
18
-
19
1
  == v0.9.0 [2015-06-01] Michael Granger <ged@FaerieMUD.org>
20
2
 
21
3
  Improvements:
@@ -20,6 +20,7 @@ module Symphony::Statistics
20
20
  super
21
21
  @samples = []
22
22
  @sample_size = DEFAULT_SAMPLE_SIZE
23
+ @counter = 0
23
24
  end
24
25
 
25
26
 
@@ -36,6 +37,7 @@ module Symphony::Statistics
36
37
  def add_sample( value )
37
38
  @samples << [ Time.now.to_f, value ]
38
39
  @samples.pop( @samples.size - self.sample_size ) if @samples.size > self.sample_size
40
+ @counter = ( @counter + 1 ) % 3
39
41
  end
40
42
 
41
43
 
@@ -51,6 +53,13 @@ module Symphony::Statistics
51
53
  end
52
54
 
53
55
 
56
+ ### Return the mean of the job count samples.
57
+ def mean_jobcount
58
+ return 0 unless self.samples.size >= self.sample_size
59
+ return @samples.map( &:last ).reduce( :+ ) / @samples.length.to_f
60
+ end
61
+
62
+
54
63
  ### Predict the likelihood that an upward trend will continue based on linear regression
55
64
  ### analysis of the given samples. If the value returned is >= 3.0, the values are
56
65
  ### statistically trending upwards, which in Symphony's case means that the workers are
@@ -87,7 +96,9 @@ module Symphony::Statistics
87
96
 
88
97
  stde = Math.sqrt( (r / ( samples.size - 2 )) / s )
89
98
 
90
- # Loggability[ Symphony ].debug " job sampling trend is: %f" % [ slope / stde ]
99
+ # Loggability[ Symphony ].debug " job sampling trend is: %f" % [ slope / stde ] if
100
+ # @counter.zero?
101
+
91
102
  return slope / stde
92
103
  end
93
104
 
data/lib/symphony/task.rb CHANGED
@@ -346,8 +346,7 @@ class Symphony::Task
346
346
  end
347
347
 
348
348
  self.last_worked = Time.now
349
- rval
350
- end
349
+ end
351
350
 
352
351
  return rval
353
352
  end
@@ -34,8 +34,14 @@ class Symphony::TaskGroup::LongLived < Symphony::TaskGroup
34
34
  def needs_a_worker?
35
35
  return true unless self.started_one_worker?
36
36
  return false unless @queue
37
- return false if @queue.consumer_count >= self.max_workers
38
- return self.sample_values_increasing?
37
+ if ( cc = @queue.consumer_count ) >= self.max_workers
38
+ self.log.debug "Already at max workers (%d)" % [ self.max_workers ]
39
+ return false
40
+ else
41
+ self.log.debug "Not yet at max workers (have %d)" % [ cc ]
42
+ end
43
+ self.log.debug "Mean jobcount is %0.2f" % [ self.mean_jobcount ]
44
+ return self.mean_jobcount > 1 && !self.sample_values_decreasing?
39
45
  end
40
46
 
41
47
 
data/lib/symphony.rb CHANGED
@@ -12,10 +12,10 @@ module Symphony
12
12
  Configurability
13
13
 
14
14
  # Library version constant
15
- VERSION = '0.9.2'
15
+ VERSION = '0.10.0'
16
16
 
17
17
  # Version-control revision constant
18
- REVISION = %q$Revision: 4171fb773f62 $
18
+ REVISION = %q$Revision: ade5a2647590 $
19
19
 
20
20
 
21
21
  # The name of the environment variable to check for config file overrides
@@ -28,6 +28,15 @@ describe Symphony::TaskGroup::LongLived do
28
28
  described_class.new( task, 2 )
29
29
  end
30
30
 
31
+ let( :pid_generator ) do
32
+ Enumerator.new do |generator|
33
+ i = 414
34
+ loop do
35
+ generator.yield( i )
36
+ i += rand( 3 ) + 1
37
+ end
38
+ end
39
+ end
31
40
 
32
41
  # not enough samples
33
42
  # trending up
@@ -46,8 +55,12 @@ describe Symphony::TaskGroup::LongLived do
46
55
 
47
56
  context "when told to adjust its worker pool" do
48
57
 
58
+ before( :each ) do
59
+ allow( Process ).to receive( :fork ) { pid_generator.next }
60
+ end
61
+
62
+
49
63
  it "starts an initial worker if it doesn't have any" do
50
- expect( Process ).to receive( :fork ).and_return( 414 )
51
64
  allow( Process ).to receive( :setpgid ).with( 414, 0 )
52
65
 
53
66
  channel = double( Bunny::Channel )
@@ -69,7 +82,6 @@ describe Symphony::TaskGroup::LongLived do
69
82
  samples = [ 1, 2, 2, 3, 3, 3, 4 ]
70
83
  task_group.sample_size = samples.size
71
84
 
72
- expect( Process ).to receive( :fork ).and_return( 525, 528 )
73
85
  allow( Process ).to receive( :setpgid )
74
86
 
75
87
  channel = double( Bunny::Channel )
@@ -80,7 +92,9 @@ describe Symphony::TaskGroup::LongLived do
80
92
  with( task.queue_name, passive: true, prefetch: 0 ).
81
93
  and_return( queue )
82
94
 
83
- allow( queue ).to receive( :consumer_count ).and_return( 1 )
95
+ expect( queue ).to receive( :consumer_count ) do
96
+ task_group.pids.size
97
+ end.at_least( :once )
84
98
  expect( queue ).to receive( :message_count ).and_return( *samples )
85
99
 
86
100
  start = 1414002605
@@ -91,16 +105,15 @@ describe Symphony::TaskGroup::LongLived do
91
105
  end
92
106
 
93
107
  expect( task_group.started_one_worker? ).to be_truthy
94
- expect( task_group.pids ).to include( 525, 528 )
108
+ expect( task_group.pids ).to include( 414 )
109
+ expect( task_group.pids.length ).to eq( 2 )
95
110
  end
96
111
 
97
112
 
98
113
  it "starts an additional worker if its work load is holding steady at a non-zero value" do
99
- pending "this being a problem we see in practice"
100
114
  samples = [ 4, 4, 4, 5, 5, 4, 4 ]
101
- task_group.sample_size = samples.size
115
+ task_group.sample_size = samples.size - 3
102
116
 
103
- expect( Process ).to receive( :fork ).and_return( 525, 528 )
104
117
  allow( Process ).to receive( :setpgid )
105
118
 
106
119
  channel = double( Bunny::Channel )
@@ -111,7 +124,9 @@ describe Symphony::TaskGroup::LongLived do
111
124
  with( task.queue_name, passive: true, prefetch: 0 ).
112
125
  and_return( queue )
113
126
 
114
- allow( queue ).to receive( :consumer_count ).and_return( 1 )
127
+ expect( queue ).to receive( :consumer_count ) do
128
+ task_group.pids.size
129
+ end.at_least( :once )
115
130
  expect( queue ).to receive( :message_count ).and_return( *samples )
116
131
 
117
132
  start = 1414002605
@@ -126,11 +141,9 @@ describe Symphony::TaskGroup::LongLived do
126
141
 
127
142
 
128
143
  it "doesn't start a worker if it's already running the maximum number of workers" do
129
- samples = [ 1, 2, 2, 3, 3, 3, 4, 4, 4, 5 ]
130
- consumers = [ 1, 1, 1, 1, 1, 1, 1, 2, 2, 2 ]
144
+ samples = [ 1, 2, 2, 3, 3, 3, 4, 4, 4, 5 ]
131
145
  task_group.sample_size = samples.size - 3
132
146
 
133
- expect( Process ).to receive( :fork ).and_return( 525, 528 )
134
147
  allow( Process ).to receive( :setpgid )
135
148
 
136
149
  channel = double( Bunny::Channel )
@@ -141,7 +154,9 @@ describe Symphony::TaskGroup::LongLived do
141
154
  with( task.queue_name, passive: true, prefetch: 0 ).
142
155
  and_return( queue )
143
156
 
144
- expect( queue ).to receive( :consumer_count ).and_return( *consumers )
157
+ expect( queue ).to receive( :consumer_count ) do
158
+ task_group.pids.size
159
+ end.at_least( :once )
145
160
  expect( queue ).to receive( :message_count ).and_return( *samples )
146
161
 
147
162
  start = 1414002605
@@ -159,7 +174,6 @@ describe Symphony::TaskGroup::LongLived do
159
174
  samples = [ 0, 1, 0, 0, 0, 0, 1, 0, 0 ]
160
175
  task_group.sample_size = samples.size - 3
161
176
 
162
- expect( Process ).to receive( :fork ).and_return( 525 )
163
177
  allow( Process ).to receive( :setpgid )
164
178
 
165
179
  channel = double( Bunny::Channel )
@@ -188,7 +202,6 @@ describe Symphony::TaskGroup::LongLived do
188
202
  samples = [ 4, 3, 3, 2, 2, 2, 1, 1, 0, 0 ]
189
203
  task_group.sample_size = samples.size
190
204
 
191
- expect( Process ).to receive( :fork ).and_return( 525 )
192
205
  allow( Process ).to receive( :setpgid )
193
206
 
194
207
  channel = double( Bunny::Channel )
@@ -199,7 +212,9 @@ describe Symphony::TaskGroup::LongLived do
199
212
  with( task.queue_name, passive: true, prefetch: 0 ).
200
213
  and_return( queue )
201
214
 
202
- allow( queue ).to receive( :consumer_count ).and_return( 1 )
215
+ expect( queue ).to receive( :consumer_count ) do
216
+ task_group.pids.size
217
+ end.at_least( :once )
203
218
  expect( queue ).to receive( :message_count ).and_return( *samples )
204
219
 
205
220
  start = 1414002605
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: symphony
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.10.0.pre20150904120928
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -31,7 +31,7 @@ cert_chain:
31
31
  G8LHR7EjtPPmqCCunfyecJ6MmCNaiJCBxq2NYzyNmluPyHT8+0fuB5kccUVZm6CD
32
32
  xn3DzOkDE6NYbk8gC9rTsA==
33
33
  -----END CERTIFICATE-----
34
- date: 2015-07-07 00:00:00.000000000 Z
34
+ date: 2015-09-04 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: configurability
@@ -356,9 +356,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
356
356
  version: 2.0.0
357
357
  required_rubygems_version: !ruby/object:Gem::Requirement
358
358
  requirements:
359
- - - ">="
359
+ - - ">"
360
360
  - !ruby/object:Gem::Version
361
- version: 2.0.3
361
+ version: 1.3.1
362
362
  requirements: []
363
363
  rubyforge_project:
364
364
  rubygems_version: 2.4.7
metadata.gz.sig CHANGED
Binary file