groonga-query-log 1.6.6 → 1.7.1

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: 4e5305ed3d2b9cfccdf3b47f63c4bda63b86c5652610693c55f635f62c40717e
4
- data.tar.gz: 951d582fe4301ba723e9ed749dbd1d90babe81f9711b17320b9072d9e473726c
3
+ metadata.gz: dc465fa277253d4a2f6f4b42ddc9553393572f6d6ad03496b17d308036f90f51
4
+ data.tar.gz: 1d458256bf29ef9d84100e66a535563d85a240f823e5dfd524bb45122bc1fa55
5
5
  SHA512:
6
- metadata.gz: 53f0433ceb544b5b88ef5229de6b6e049c836dc115f7ec723def25e2206266b9d68446c1df3af56e3bf8acaaccc7e55b2de007531d9329db7b20328c1c13d127
7
- data.tar.gz: 265f2791aab081ba71f8174b2436218a9e11eb399703eeda4be8ca99d0962d425a16505a4366f16c3a4c1b02c92fffb52ffe5c9f461f367bf7348682eacef925
6
+ metadata.gz: 1954617ef0c708f19af1a204bfd26a71cf7799204237f7be72a00c42c0aafacfc177f9785ed2f456108cad47dd3d2756cd9608eddb80780fa67a6e142e85e673
7
+ data.tar.gz: 31df2208d65ffde3cb0b25dbcac5290f080f85310d747e3e1cd89e4a11f78a50dab071ebee27048e4c6d6bf3c59da7281180657c8ecd0e2adf2495f3ac348fba
@@ -1,5 +1,51 @@
1
1
  # News
2
2
 
3
+ ## 1.7.1: 2020-06-01
4
+
5
+ ### Fixes
6
+
7
+ * `server-verifier`: Fixed a bug that performance verification with
8
+ `--stop-onlfailre` doesn't work.
9
+
10
+ * `run-regression-test`: Fixed a bug that failure is ignored.
11
+
12
+ ## 1.7.0: 2020-05-31
13
+
14
+ ### Fixes
15
+
16
+ * `server-verifier`: Fixed a bug that performance verification
17
+ doesn't work.
18
+
19
+ ## 1.6.9: 2020-05-30
20
+
21
+ ### Fixes
22
+
23
+ * `server-verifier`: Fixed a bug that performance verification
24
+ doesn't work.
25
+
26
+ ## 1.6.8: 2020-05-30
27
+
28
+ ### Improvements
29
+
30
+ * `server-verifier`: Stopped sorting elapsed times.
31
+
32
+ * `run-regression-test`: Ensured killing Groonga server on start up
33
+ error.
34
+
35
+ ## 1.6.7: 2020-05-30
36
+
37
+ ### Improvements
38
+
39
+ * `extract`: Added support for no command request case such as `/`.
40
+
41
+ * `server-verifier`: Reduced the number of requests for performance
42
+ verification.
43
+
44
+ * `server-verifier`: Added all elapsed times on slow.
45
+
46
+ * `format-regression-test-logs`: Added support for all elapsed times
47
+ on slow.
48
+
3
49
  ## 1.6.6: 2020-05-20
4
50
 
5
51
  ### Fixes
@@ -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
 
@@ -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,42 @@ 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
+ true
794
+ ensure
795
+ @old.shutdown
783
796
  end
784
797
  end
785
798
  new_thread = Thread.new do
786
- @new.run do
787
- run_test
799
+ @new.run
800
+ begin
801
+ ready_queue.push(true)
802
+ wait_queue.pop
803
+ true
804
+ ensure
805
+ @new.shutdown
788
806
  end
789
807
  end
808
+ test_thread = Thread.new do
809
+ ready_queue.pop
810
+ ready_queue.pop
811
+ success = run_test
812
+ wait_queue.push(true)
813
+ wait_queue.push(true)
814
+ success
815
+ end
790
816
 
791
817
  old_thread_success = old_thread.value
792
818
  new_thread_success = new_thread.value
819
+ test_thread_success = test_thread.value
793
820
 
794
- old_thread_success and new_thread_success
821
+ old_thread_success and new_thread_success and test_thread_success
795
822
  end
796
823
 
797
824
  def n_executed_commands
@@ -800,10 +827,7 @@ module GroongaQueryLog
800
827
 
801
828
  private
802
829
  def run_test
803
- @n_ready_waits -= 1
804
- return true unless @n_ready_waits.zero?
805
-
806
- same = true
830
+ success = true
807
831
  query_log_paths.each do |query_log_path|
808
832
  log_path = test_log_path(query_log_path)
809
833
  if @options[:skip_finished_queries] and log_path.exist?
@@ -828,24 +852,14 @@ module GroongaQueryLog
828
852
  callback = nil
829
853
  end
830
854
  unless verify_server(log_path, query_log_path, &callback)
831
- same = false
855
+ success = false
832
856
  break if @stop_on_failure
833
857
  end
834
858
  rescue Interrupt
835
859
  puts("Interrupt: #{query_log_path}")
836
860
  end
837
861
  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
- same
862
+ success
849
863
  end
850
864
 
851
865
  def verify_server(test_log_path, query_log_path, &callback)
@@ -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,48 @@ 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
+ return if stop?
215
+
216
+ responses1 << groonga1_client.execute(command)
217
+ responses2 << groonga2_client.execute(command)
218
+ verifier = PerformanceVerifier.new(command,
219
+ responses1,
220
+ responses2,
221
+ @options.performance_verifier_options)
222
+ if verifier.slow?
223
+ @slow = true
224
+ @events.push([:slow,
225
+ command,
226
+ verifier.old_elapsed_time,
227
+ verifier.new_elapsed_time,
228
+ verifier.old_elapsed_times,
229
+ verifier.new_elapsed_times])
230
+ return
231
+ end
208
232
  end
209
233
  end
210
234
 
@@ -233,11 +257,18 @@ module GroongaQueryLog
233
257
  output.flush
234
258
  end
235
259
 
236
- def report_slow(output, command, old_elapsed_time, new_elapsed_time)
260
+ def report_slow(output,
261
+ command,
262
+ old_elapsed_time,
263
+ new_elapsed_time,
264
+ old_elapsed_times,
265
+ new_elapsed_times)
237
266
  command_source = command.original_source || command.to_uri_format
238
267
  output.puts("command: #{command_source}")
239
268
  output.puts("elapsed_time_old: #{old_elapsed_time}")
240
269
  output.puts("elapsed_time_new: #{new_elapsed_time}")
270
+ output.puts("elapsed_times_old: #{old_elapsed_times.join(' ')}")
271
+ output.puts("elapsed_times_new: #{new_elapsed_times.join(' ')}")
241
272
  output.puts("elapsed_time_ratio: #{new_elapsed_time / old_elapsed_time}")
242
273
  output.flush
243
274
  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.6"
18
+ VERSION = "1.7.1"
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.6
4
+ version: 1.7.1
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-20 00:00:00.000000000 Z
11
+ date: 2020-05-31 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