groonga-query-log 1.6.5 → 1.7.0

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
  SHA256:
3
- metadata.gz: 5491daf99859078f656e26f3f1445eadbef319899eda9dadf806415916e25e9d
4
- data.tar.gz: '0192e216e446888ed26a5fd6372bdd62a56759eea24eac06bac441d5d133cb79'
3
+ metadata.gz: 137657847fe22ae9bd436e1a2a99467c93cc7134cde90f710451f1d6c205c083
4
+ data.tar.gz: 68455fe3c51c12a8b1ee1a5106d99ff86a52b14eebbd2077b2284523fe560498
5
5
  SHA512:
6
- metadata.gz: 26a03dadf837f274d139c7743dc4682c28a2961348f7dd4d49674591fbfb879dcf928584b0e521800a3f97dc574e717b8ec6b9d2dc3a7fac596f6949ef2779d1
7
- data.tar.gz: 75f4dfbf7010ed8d4e5db8c832eacc4274b8b62720ccbef4ea37ff0cb4b5ba138533c99328c33684c93adce8c23e459b4a906c95591f51b025d05128fa3890da
6
+ metadata.gz: baa54b40acddcb3c6b2fe46a4a7566eb402dc4f1be8327200832614ee3274e6de49116b644bf149c7d87dcc58f920e61ddb81a5c0486c4648164bc6a3503d4f9
7
+ data.tar.gz: 747d1d1fc84cbeabf2445882e7d70274c6b94994787ea056150c9a18f661992436a29acded2d19cb0a152a2159ef0d7c29dca9e0b8690f82564873f31f99ef35
@@ -1,5 +1,49 @@
1
1
  # News
2
2
 
3
+ ## 1.7.0: 2020-05-31
4
+
5
+ ### Fixes
6
+
7
+ * `server-verifier`: Fixed a bug that performance verification
8
+ doesn't work.
9
+
10
+ ## 1.6.9: 2020-05-30
11
+
12
+ ### Fixes
13
+
14
+ * `server-verifier`: Fixed a bug that performance verification
15
+ doesn't work.
16
+
17
+ ## 1.6.8: 2020-05-30
18
+
19
+ ### Improvements
20
+
21
+ * `server-verifier`: Stopped sorting elapsed times.
22
+
23
+ * `run-regression-test`: Ensured killing Groonga server on start up
24
+ error.
25
+
26
+ ## 1.6.7: 2020-05-30
27
+
28
+ ### Improvements
29
+
30
+ * `extract`: Added support for no command request case such as `/`.
31
+
32
+ * `server-verifier`: Reduced the number of requests for performance
33
+ verification.
34
+
35
+ * `server-verifier`: Added all elapsed times on slow.
36
+
37
+ * `format-regression-test-logs`: Added support for all elapsed times
38
+ on slow.
39
+
40
+ ## 1.6.6: 2020-05-20
41
+
42
+ ### Fixes
43
+
44
+ * `run-regression-test`: Fixed a bug that
45
+ `--old-groonga-warm-up-command` is ignored.
46
+
3
47
  ## 1.6.5: 2020-05-19
4
48
 
5
49
  ### Improvements
@@ -182,6 +182,8 @@ module GroongaQueryLog
182
182
  end
183
183
 
184
184
  def target?(command)
185
+ return false if command.nil?
186
+
185
187
  name = command.command_name
186
188
  target_commands = @options.commands
187
189
  exclude_commands = @options.exclude_commands
@@ -74,6 +74,8 @@ module GroongaQueryLog
74
74
  elapsed_time_old = nil
75
75
  elapsed_time_new = nil
76
76
  elapsed_time_ratio = nil
77
+ elapsed_times_old = nil
78
+ elapsed_times_new = nil
77
79
 
78
80
  input.each_line do |line|
79
81
  unless line.valid_encoding?
@@ -100,11 +102,21 @@ module GroongaQueryLog
100
102
  elapsed_time_old = Float($POSTMATCH.chomp)
101
103
  when /\Aelapsed_time_new: /
102
104
  elapsed_time_new = Float($POSTMATCH.chomp)
105
+ when /\Aelapsed_times_old: /
106
+ elapsed_times_old = $POSTMATCH.chomp.split.collect do |value|
107
+ Float(value)
108
+ end
109
+ when /\Aelapsed_times_new: /
110
+ elapsed_times_new = $POSTMATCH.chomp.split.collect do |value|
111
+ Float(value)
112
+ end
103
113
  when /\Aelapsed_time_ratio: /
104
114
  elapsed_time_ratio = Float($POSTMATCH.chomp)
105
115
  report_slow(command,
106
116
  elapsed_time_old,
107
117
  elapsed_time_new,
118
+ elapsed_times_old,
119
+ elapsed_times_new,
108
120
  elapsed_time_ratio)
109
121
  end
110
122
  end
@@ -196,11 +208,21 @@ module GroongaQueryLog
196
208
  def report_slow(command,
197
209
  elapsed_time_old,
198
210
  elapsed_time_new,
211
+ elapsed_times_old,
212
+ elapsed_times_new,
199
213
  elapsed_time_ratio)
200
214
  report_command(command)
215
+ elapsed_times_old ||= [elapsed_time_old]
216
+ elapsed_times_new ||= [elapsed_time_new]
201
217
  @output.puts("Slow:")
202
- @output.puts(" Old: %s" % format_elapsed_time(elapsed_time_old))
203
- @output.puts(" New: %s" % format_elapsed_time(elapsed_time_new))
218
+ @output.puts(" Old: %s (%s)" % [
219
+ format_elapsed_time(elapsed_time_old),
220
+ format_elapsed_times(elapsed_times_old),
221
+ ])
222
+ @output.puts(" New: %s (%s)" % [
223
+ format_elapsed_time(elapsed_time_new),
224
+ format_elapsed_times(elapsed_times_new),
225
+ ])
204
226
  @output.puts(" Ratio: +%.1f%%" % ((elapsed_time_ratio * 100) - 100))
205
227
  end
206
228
 
@@ -212,7 +212,7 @@ module GroongaQueryLog
212
212
  @new_groonga_env[key] = value
213
213
  end
214
214
 
215
- parser.on("--old-groonga-warm-up-commands=COMMAND",
215
+ parser.on("--new-groonga-warm-up-commands=COMMAND",
216
216
  "Run COMMAND before running tests to warm new groonga up",
217
217
  "You can specify this option multiple times",
218
218
  "to specify multiple warm up commands",
@@ -559,6 +559,7 @@ module GroongaQueryLog
559
559
  @host = "127.0.0.1"
560
560
  @port = find_unused_port
561
561
  @options = options
562
+ @pid = nil
562
563
  end
563
564
 
564
565
  def run
@@ -579,25 +580,28 @@ module GroongaQueryLog
579
580
  spawn_args << @database_path.to_s
580
581
  @pid = spawn(*spawn_args)
581
582
 
582
- n_retries = 10
583
583
  begin
584
- send_command("status")
585
- rescue SystemCallError
586
- sleep(1)
587
- n_retries -= 1
588
- raise if n_retries.zero?
589
- retry
590
- end
584
+ n_retries = 60
585
+ begin
586
+ send_command("status")
587
+ rescue SystemCallError
588
+ sleep(1)
589
+ n_retries -= 1
590
+ raise if n_retries.zero?
591
+ retry
592
+ end
591
593
 
592
- if @options[:warm_up]
593
- send_command("dump?dump_records=no")
594
- warm_up_commands = @options[:warm_up_commands] || []
595
- warm_up_commands.each do |command|
596
- send_command(command)
594
+ if @options[:warm_up]
595
+ send_command("dump?dump_records=no")
596
+ warm_up_commands = @options[:warm_up_commands] || []
597
+ warm_up_commands.each do |command|
598
+ send_command(command)
599
+ end
597
600
  end
601
+ rescue
602
+ shutdown
603
+ raise
598
604
  end
599
-
600
- yield if block_given?
601
605
  end
602
606
 
603
607
  def ensure_database
@@ -688,11 +692,14 @@ module GroongaQueryLog
688
692
  end
689
693
 
690
694
  def shutdown
695
+ return if @pid.nil?
691
696
  begin
692
697
  send_command("shutdown")
693
698
  rescue SystemCallError
699
+ Process.kill(:KILL, @pid)
694
700
  end
695
701
  Process.waitpid(@pid)
702
+ @pid = nil
696
703
  end
697
704
 
698
705
  def n_leaked_objects
@@ -769,7 +776,6 @@ module GroongaQueryLog
769
776
  @n_clients = options[:n_clients] || 1
770
777
  @stop_on_failure = options[:stop_on_failure]
771
778
  @options = options
772
- @n_ready_waits = 2
773
779
  @n_executed_commands = 0
774
780
  end
775
781
 
@@ -777,21 +783,39 @@ module GroongaQueryLog
777
783
  @old.ensure_database
778
784
  @new.ensure_database
779
785
 
786
+ ready_queue = Thread::Queue.new
787
+ wait_queue = Thread::Queue.new
780
788
  old_thread = Thread.new do
781
- @old.run do
782
- run_test
789
+ @old.run
790
+ begin
791
+ ready_queue.push(true)
792
+ wait_queue.pop
793
+ ensure
794
+ @old.shutdown
783
795
  end
784
796
  end
785
797
  new_thread = Thread.new do
786
- @new.run do
787
- run_test
798
+ @new.run
799
+ begin
800
+ ready_queue.push(true)
801
+ wait_queue.pop
802
+ ensure
803
+ @new.shutdown
788
804
  end
789
805
  end
806
+ test_thread = Thread.new do
807
+ ready_queue.pop
808
+ ready_queue.pop
809
+ run_test
810
+ wait_queue.push(true)
811
+ wait_queue.push(true)
812
+ end
790
813
 
791
814
  old_thread_success = old_thread.value
792
815
  new_thread_success = new_thread.value
816
+ test_thread_success = test_thread.value
793
817
 
794
- old_thread_success and new_thread_success
818
+ old_thread_success and new_thread_success and test_thread_success
795
819
  end
796
820
 
797
821
  def n_executed_commands
@@ -800,9 +824,6 @@ module GroongaQueryLog
800
824
 
801
825
  private
802
826
  def run_test
803
- @n_ready_waits -= 1
804
- return true unless @n_ready_waits.zero?
805
-
806
827
  same = true
807
828
  query_log_paths.each do |query_log_path|
808
829
  log_path = test_log_path(query_log_path)
@@ -835,16 +856,6 @@ module GroongaQueryLog
835
856
  puts("Interrupt: #{query_log_path}")
836
857
  end
837
858
  end
838
-
839
- old_thread = Thread.new do
840
- @old.shutdown
841
- end
842
- new_thread = Thread.new do
843
- @new.shutdown
844
- end
845
- old_thread.join
846
- new_thread.join
847
-
848
859
  same
849
860
  end
850
861
 
@@ -30,5 +30,12 @@ module GroongaQueryLog
30
30
  "%.1fmin" % (elapsed_time / 60)
31
31
  end
32
32
  end
33
+
34
+ def format_elapsed_times(elapsed_times)
35
+ formatted_epalsed_times = elapsed_times.collect do |elapsed_time|
36
+ format_elapsed_time(elapsed_time)
37
+ end
38
+ formatted_epalsed_times.join(" ")
39
+ end
33
40
  end
34
41
  end
@@ -47,10 +47,18 @@ module GroongaQueryLog
47
47
  diff_ratio > @threshold_ratio
48
48
  end
49
49
 
50
+ def old_elapsed_times
51
+ collect_elapsed_times(@old_responses)
52
+ end
53
+
50
54
  def old_elapsed_time
51
55
  choose_target_elapsed_time(@old_responses)
52
56
  end
53
57
 
58
+ def new_elapsed_times
59
+ collect_elapsed_times(@new_responses)
60
+ end
61
+
54
62
  def new_elapsed_time
55
63
  choose_target_elapsed_time(@new_responses)
56
64
  end
@@ -66,18 +74,21 @@ module GroongaQueryLog
66
74
  end
67
75
  end
68
76
 
69
- def choose_target_elapsed_time(responses)
70
- elapsed_times = responses.collect do |response|
77
+ def collect_elapsed_times(responses)
78
+ responses.collect do |response|
71
79
  response.elapsed_time
72
80
  end
73
- sorted_elapsed_times = elapsed_times.sort
81
+ end
82
+
83
+ def choose_target_elapsed_time(responses)
84
+ sorted_elapsed_times = collect_elapsed_times(responses).sort
74
85
 
75
86
  strategy = @options.choose_strategy
76
87
  case strategy
77
88
  when :fastest
78
89
  sorted_elapsed_times.first
79
90
  when :median
80
- sorted_elapsed_times[elapsed_times.size / 2]
91
+ sorted_elapsed_times[sorted_elapsed_times.size / 2]
81
92
  else
82
93
  message =
83
94
  "choose strategy must be :fastest or :median: #{strategy.inspect}"
@@ -187,24 +187,46 @@ module GroongaQueryLog
187
187
  return
188
188
  end
189
189
 
190
- return unless @options.verify_performance?
190
+ if @options.verify_performance?
191
+ verify_performance(command,
192
+ groonga1_client,
193
+ groonga2_client,
194
+ response1,
195
+ response2)
196
+ end
197
+ end
198
+
199
+ def verify_performance(command,
200
+ groonga1_client,
201
+ groonga2_client,
202
+ response1,
203
+ response2)
191
204
  responses1 = [response1]
192
205
  responses2 = [response2]
193
- n_tries = 4
194
- n_tries.times do
195
- responses1 << groonga1_client.execute(command)
196
- responses2 << groonga2_client.execute(command)
197
- end
198
206
  verifier = PerformanceVerifier.new(command,
199
207
  responses1,
200
208
  responses2,
201
209
  @options.performance_verifier_options)
202
- if verifier.slow?
203
- @slow = true
204
- @events.push([:slow,
205
- command,
206
- verifier.old_elapsed_time,
207
- verifier.new_elapsed_time])
210
+ return unless verifier.slow?
211
+
212
+ n_tries = 4
213
+ n_tries.times do
214
+ responses1 << groonga1_client.execute(command)
215
+ responses2 << groonga2_client.execute(command)
216
+ verifier = PerformanceVerifier.new(command,
217
+ responses1,
218
+ responses2,
219
+ @options.performance_verifier_options)
220
+ if verifier.slow?
221
+ @slow = true
222
+ @events.push([:slow,
223
+ command,
224
+ verifier.old_elapsed_time,
225
+ verifier.new_elapsed_time,
226
+ verifier.old_elapsed_times,
227
+ verifier.new_elapsed_times])
228
+ return
229
+ end
208
230
  end
209
231
  end
210
232
 
@@ -233,11 +255,18 @@ module GroongaQueryLog
233
255
  output.flush
234
256
  end
235
257
 
236
- def report_slow(output, command, old_elapsed_time, new_elapsed_time)
258
+ def report_slow(output,
259
+ command,
260
+ old_elapsed_time,
261
+ new_elapsed_time,
262
+ old_elapsed_times,
263
+ new_elapsed_times)
237
264
  command_source = command.original_source || command.to_uri_format
238
265
  output.puts("command: #{command_source}")
239
266
  output.puts("elapsed_time_old: #{old_elapsed_time}")
240
267
  output.puts("elapsed_time_new: #{new_elapsed_time}")
268
+ output.puts("elapsed_times_old: #{old_elapsed_times.join(' ')}")
269
+ output.puts("elapsed_times_new: #{new_elapsed_times.join(' ')}")
241
270
  output.puts("elapsed_time_ratio: #{new_elapsed_time / old_elapsed_time}")
242
271
  output.flush
243
272
  end
@@ -15,5 +15,5 @@
15
15
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
  module GroongaQueryLog
18
- VERSION = "1.6.5"
18
+ VERSION = "1.7.0"
19
19
  end
@@ -109,14 +109,32 @@ Arguments:
109
109
  query: column_create
110
110
  table: Entries
111
111
  Slow:
112
- Old: 174.8usec
113
- New: 201.7usec
112
+ Old: 174.8usec (174.8usec)
113
+ New: 201.7usec (201.7usec)
114
114
  Ratio: +15.4%
115
115
  OUTPUT
116
116
  assert_equal([true, output],
117
117
  run_command([fixture_path("slow.log")]))
118
118
  end
119
119
 
120
+ def test_slow_elapsed_times
121
+ output = <<-OUTPUT
122
+ Command:
123
+ /d/select?match_columns=description&query=column_create&table=Entries
124
+ Name: select
125
+ Arguments:
126
+ match_columns: description
127
+ query: column_create
128
+ table: Entries
129
+ Slow:
130
+ Old: 174.8usec (174.8usec 184.8usec)
131
+ New: 201.7usec (201.7usec 211.7usec)
132
+ Ratio: +15.4%
133
+ OUTPUT
134
+ assert_equal([true, output],
135
+ run_command([fixture_path("slow-elapsed-times.log")]))
136
+ end
137
+
120
138
  sub_test_case(".new") do
121
139
  def setup
122
140
  end
@@ -0,0 +1,6 @@
1
+ command: /d/select?match_columns=description&query=column_create&table=Entries
2
+ elapsed_time_old: 0.0001747608184814453
3
+ elapsed_time_new: 0.0002017021179199219
4
+ elapsed_times_old: 0.0001747608184814453 0.0001847608184814453
5
+ elapsed_times_new: 0.0002017021179199219 0.0002117021179199219
6
+ elapsed_time_ratio: 1.154160982264666
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groonga-query-log
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.5
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-18 00:00:00.000000000 Z
11
+ date: 2020-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: charty
@@ -272,6 +272,7 @@ files:
272
272
  - test/fixtures/query.log
273
273
  - test/fixtures/regression-test-logs/command-format.log
274
274
  - test/fixtures/regression-test-logs/error.log
275
+ - test/fixtures/regression-test-logs/slow-elapsed-times.log
275
276
  - test/fixtures/regression-test-logs/slow.log
276
277
  - test/fixtures/regression-test-logs/url-format.log
277
278
  - test/fixtures/reporter/console.expected
@@ -345,6 +346,7 @@ test_files:
345
346
  - test/fixtures/query.log
346
347
  - test/fixtures/regression-test-logs/command-format.log
347
348
  - test/fixtures/regression-test-logs/error.log
349
+ - test/fixtures/regression-test-logs/slow-elapsed-times.log
348
350
  - test/fixtures/regression-test-logs/slow.log
349
351
  - test/fixtures/regression-test-logs/url-format.log
350
352
  - test/fixtures/reporter/console.expected