groonga-query-log 1.6.4 → 1.6.9

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: d2d80e83a4e97eef62575b74225fb3906bba84cfdfe27d3322f57cc6a2a5ecad
4
- data.tar.gz: a9c6085392cc0be54614d2d6cf465b716718867d54274968afe69ed06c93f2b8
3
+ metadata.gz: a6c1fa15ed54fa3eb2c15e9791c4dbf7c9cd7109b2384954c384ff5fad69059c
4
+ data.tar.gz: 656d2240444743749d32b1304164d75f30a6c462bd938fae28aa9dda6be0f74d
5
5
  SHA512:
6
- metadata.gz: b861443cf20f694818b4457a3e657a09bc5b3aef46e30e3173445216d945b91ead35e4b03c955110ebad03485c111f47cc9f08b1ad314b57909d982c869e44c2
7
- data.tar.gz: f429713e01e280273e2511f02b121e50d5999ef38b9a5531402690a8bb1bf8f13e57fe499f11c3981eedee12dba29766c2144c4676bd133bc3da4f1f343d2c40
6
+ metadata.gz: 93b3bd2a44c10f675856317c69ba9d2abe12f48ead686272d32f611f552278e2ac14f05917eee5c26555ccd17fc18c9c5c81dc2dbcf64e5a8a85e25b02be88a2
7
+ data.tar.gz: d83aebd5c4bff439c65de360ebf44244a3c1ba8c0ec7fb4477081d7c73418b3db0d867ba9cf21ab548c0eab4f784dd596c9d570e847effe5c1bbb4cd332fe4db
@@ -1,5 +1,52 @@
1
1
  # News
2
2
 
3
+ ## 1.6.9: 2020-05-30
4
+
5
+ ### Fixes
6
+
7
+ * `server-verifier`: Fixed a bug that performance verification
8
+ doesn't work.
9
+
10
+ ## 1.6.8: 2020-05-30
11
+
12
+ ### Improvements
13
+
14
+ * `server-verifier`: Stopped sorting elapsed times.
15
+
16
+ * `run-regression-test`: Ensured killing Groonga server on start up
17
+ error.
18
+
19
+ ## 1.6.7: 2020-05-30
20
+
21
+ ### Improvements
22
+
23
+ * `extract`: Added support for no command request case such as `/`.
24
+
25
+ * `server-verifier`: Reduced the number of requests for performance
26
+ verification.
27
+
28
+ * `server-verifier`: Added all elapsed times on slow.
29
+
30
+ * `format-regression-test-logs`: Added support for all elapsed times
31
+ on slow.
32
+
33
+ ## 1.6.6: 2020-05-20
34
+
35
+ ### Fixes
36
+
37
+ * `run-regression-test`: Fixed a bug that
38
+ `--old-groonga-warm-up-command` is ignored.
39
+
40
+ ## 1.6.5: 2020-05-19
41
+
42
+ ### Improvements
43
+
44
+ * `run-regression-test`: Added options to customize how to warm up:
45
+
46
+ * `--old-groonga-warm-up-command`
47
+
48
+ * `--new-groonga-warm-up-command`
49
+
3
50
  ## 1.6.4: 2020-05-18
4
51
 
5
52
  ### 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
 
@@ -42,11 +42,13 @@ module GroongaQueryLog
42
42
  @old_database = "db.old/db"
43
43
  @old_groonga_options = []
44
44
  @old_groonga_env = {}
45
+ @old_groonga_warm_up_commands = []
45
46
 
46
47
  @new_groonga = "groonga"
47
48
  @new_database = "db.new/db"
48
49
  @new_groonga_options = []
49
50
  @new_groonga_env = {}
51
+ @new_groonga_warm_up_commands = []
50
52
 
51
53
  @recreate_database = false
52
54
  @warm_up = true
@@ -177,6 +179,14 @@ module GroongaQueryLog
177
179
  @old_groonga_env[key] = value
178
180
  end
179
181
 
182
+ parser.on("--old-groonga-warm-up-commands=COMMAND",
183
+ "Run COMMAND before running tests to warm old groonga up",
184
+ "You can specify this option multiple times",
185
+ "to specify multiple warm up commands",
186
+ "(no additional warm up commands)") do |command|
187
+ @old_groonga_warm_up_commands << command
188
+ end
189
+
180
190
  parser.separator("")
181
191
  parser.separator("New Groonga:")
182
192
  parser.on("--new-groonga=GROONGA",
@@ -202,6 +212,14 @@ module GroongaQueryLog
202
212
  @new_groonga_env[key] = value
203
213
  end
204
214
 
215
+ parser.on("--new-groonga-warm-up-commands=COMMAND",
216
+ "Run COMMAND before running tests to warm new groonga up",
217
+ "You can specify this option multiple times",
218
+ "to specify multiple warm up commands",
219
+ "(no additional warm up commands)") do |command|
220
+ @new_groonga_warm_up_commands << command
221
+ end
222
+
205
223
  parser.separator("")
206
224
  parser.separator("Operations:")
207
225
  parser.on("--recreate-database",
@@ -457,19 +475,23 @@ module GroongaQueryLog
457
475
  end
458
476
 
459
477
  def old_groonga_server
478
+ options = server_options
479
+ options[:warm_up_commands] = @old_groonga_warm_up_commands
460
480
  GroongaServer.new(@old_groonga,
461
481
  @old_groonga_options,
462
482
  @old_groonga_env,
463
483
  @old_database,
464
- server_options)
484
+ options)
465
485
  end
466
486
 
467
487
  def new_groonga_server
488
+ options = server_options
489
+ options[:warm_up_commands] = @new_groonga_warm_up_commands
468
490
  GroongaServer.new(@new_groonga,
469
491
  @new_groonga_options,
470
492
  @new_groonga_env,
471
493
  @new_database,
472
- server_options)
494
+ options)
473
495
  end
474
496
 
475
497
  def format_report(success,
@@ -537,6 +559,7 @@ module GroongaQueryLog
537
559
  @host = "127.0.0.1"
538
560
  @port = find_unused_port
539
561
  @options = options
562
+ @pid = nil
540
563
  end
541
564
 
542
565
  def run
@@ -557,21 +580,28 @@ module GroongaQueryLog
557
580
  spawn_args << @database_path.to_s
558
581
  @pid = spawn(*spawn_args)
559
582
 
560
- n_retries = 10
561
583
  begin
562
- send_command("status")
563
- rescue SystemCallError
564
- sleep(1)
565
- n_retries -= 1
566
- raise if n_retries.zero?
567
- retry
568
- 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
569
593
 
570
- if @options[:warm_up]
571
- send_command("dump?dump_records=no")
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
600
+ end
601
+ rescue
602
+ shutdown
603
+ raise
572
604
  end
573
-
574
- yield if block_given?
575
605
  end
576
606
 
577
607
  def ensure_database
@@ -662,11 +692,14 @@ module GroongaQueryLog
662
692
  end
663
693
 
664
694
  def shutdown
695
+ return if @pid.nil?
665
696
  begin
666
697
  send_command("shutdown")
667
698
  rescue SystemCallError
699
+ Process.kill(:KILL, @pid)
668
700
  end
669
701
  Process.waitpid(@pid)
702
+ @pid = nil
670
703
  end
671
704
 
672
705
  def n_leaked_objects
@@ -743,7 +776,6 @@ module GroongaQueryLog
743
776
  @n_clients = options[:n_clients] || 1
744
777
  @stop_on_failure = options[:stop_on_failure]
745
778
  @options = options
746
- @n_ready_waits = 2
747
779
  @n_executed_commands = 0
748
780
  end
749
781
 
@@ -751,21 +783,39 @@ module GroongaQueryLog
751
783
  @old.ensure_database
752
784
  @new.ensure_database
753
785
 
786
+ ready_queue = Thread::Queue.new
787
+ wait_queue = Thread::Queue.new
754
788
  old_thread = Thread.new do
755
- @old.run do
756
- run_test
789
+ @old.run
790
+ begin
791
+ ready_queue.push(true)
792
+ wait_queue.pop
793
+ ensure
794
+ @old.shutdown
757
795
  end
758
796
  end
759
797
  new_thread = Thread.new do
760
- @new.run do
761
- run_test
798
+ @new.run
799
+ begin
800
+ ready_queue.push(true)
801
+ wait_queue.pop
802
+ ensure
803
+ @new.shutdown
762
804
  end
763
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
764
813
 
765
814
  old_thread_success = old_thread.value
766
815
  new_thread_success = new_thread.value
816
+ test_thread_success = test_thread.value
767
817
 
768
- old_thread_success and new_thread_success
818
+ old_thread_success and new_thread_success and test_thread_success
769
819
  end
770
820
 
771
821
  def n_executed_commands
@@ -774,9 +824,6 @@ module GroongaQueryLog
774
824
 
775
825
  private
776
826
  def run_test
777
- @n_ready_waits -= 1
778
- return true unless @n_ready_waits.zero?
779
-
780
827
  same = true
781
828
  query_log_paths.each do |query_log_path|
782
829
  log_path = test_log_path(query_log_path)
@@ -809,16 +856,6 @@ module GroongaQueryLog
809
856
  puts("Interrupt: #{query_log_path}")
810
857
  end
811
858
  end
812
-
813
- old_thread = Thread.new do
814
- @old.shutdown
815
- end
816
- new_thread = Thread.new do
817
- @new.shutdown
818
- end
819
- old_thread.join
820
- new_thread.join
821
-
822
859
  same
823
860
  end
824
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_time,
227
+ verifier.new_elapsed_time])
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.4"
18
+ VERSION = "1.6.9"
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.4
4
+ version: 1.6.9
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-17 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