groonga-query-log 1.6.2 → 1.6.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 292e6cac875522bbe44ce9e3ba9720662607e73e2caff72dbb64ef01b403c353
4
- data.tar.gz: 7c8ca5a6868504360814aae0c8726cdcbe909ba1806aa8a4c99e1b5324b85087
3
+ metadata.gz: 5fc818af1a75fea77eee79dc2b7852598ef14796e67a14d043449eebd31b3a15
4
+ data.tar.gz: 6c101e1c990a46aabc47208b1625db3db90152cbba9c7163fc5ee0e201b7f7a1
5
5
  SHA512:
6
- metadata.gz: 7ba5b0df58160f31cee7f9acb675bbd5c79b4f878550b184112ca8b557b591007cf8d32477beb7455e21737924785dba8305c2242a7e267a0e12b67bd3c14de6
7
- data.tar.gz: 5be7b4777f3153332cea06f6b942b121a4983136dcf6b804f8c0e699b43b2fe70636a7cd8a0da9f4c240a6d2103c0b316e96c8afab659821d40cf0c78a6ea1b2
6
+ metadata.gz: 942d6b83901dcc4b2bccf8c8639da85cfac8472db3bd59738a8f386b9811c7bb141a7718a3140043b68cef0c71e3434cafabd9686e18a685ca49e0918da24321
7
+ data.tar.gz: 23c25f00387e3755908222434477d487c7f5f1a707c54f4a86d2969a17c3bb2fcfffbfe88bee7e157651665956b42aa3d27b1d54f2ac9d5246361886be235028
@@ -1,5 +1,48 @@
1
1
  # News
2
2
 
3
+ ## 1.6.7: 2020-05-30
4
+
5
+ ### Improves
6
+
7
+ * `extract`: Added support for no command request case such as `/`.
8
+
9
+ * `server-verifier`: Reduced the number of requests for performance
10
+ verification.
11
+
12
+ * `server-verifier`: Added all elapsed times on slow.
13
+
14
+ * `format-regression-test-logs`: Added support for all elapsed times
15
+ on slow.
16
+
17
+ ## 1.6.6: 2020-05-20
18
+
19
+ ### Fixes
20
+
21
+ * `run-regression-test`: Fixed a bug that
22
+ `--old-groonga-warm-up-command` is ignored.
23
+
24
+ ## 1.6.5: 2020-05-19
25
+
26
+ ### Improvements
27
+
28
+ * `run-regression-test`: Added options to customize how to warm up:
29
+
30
+ * `--old-groonga-warm-up-command`
31
+
32
+ * `--new-groonga-warm-up-command`
33
+
34
+ ## 1.6.4: 2020-05-18
35
+
36
+ ### Improvements
37
+
38
+ * `run-regression-test`: Improved how to warm up.
39
+
40
+ ## 1.6.3: 2020-05-11
41
+
42
+ ### Improvements
43
+
44
+ * `run-regression-test`: Added `--no-warm-up` option.
45
+
3
46
  ## 1.6.2: 2020-05-09
4
47
 
5
48
  ### 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,13 +42,16 @@ 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
54
+ @warm_up = true
52
55
  @load_data = true
53
56
  @run_queries = true
54
57
  @skip_finished_queries = false
@@ -176,6 +179,14 @@ module GroongaQueryLog
176
179
  @old_groonga_env[key] = value
177
180
  end
178
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
+
179
190
  parser.separator("")
180
191
  parser.separator("New Groonga:")
181
192
  parser.on("--new-groonga=GROONGA",
@@ -201,19 +212,34 @@ module GroongaQueryLog
201
212
  @new_groonga_env[key] = value
202
213
  end
203
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
+
204
223
  parser.separator("")
205
224
  parser.separator("Operations:")
206
225
  parser.on("--recreate-database",
207
226
  "Always recreate Groonga database") do
208
227
  @recreate_database = true
209
228
  end
229
+ parser.on("--no-warm-up",
230
+ "Don't warm up before test",
231
+ "(#{@warm_up})") do |boolean|
232
+ @warm_up = boolean
233
+ end
210
234
  parser.on("--no-load-data",
211
- "Don't load data. Just loads schema to Groonga database") do
212
- @load_data = false
235
+ "Don't load data. Just loads schema to Groonga database",
236
+ "(#{@load_data})") do |boolean|
237
+ @load_data = boolean
213
238
  end
214
239
  parser.on("--no-run-queries",
215
- "Don't run queries. Just creates Groonga database") do
216
- @run_queries = false
240
+ "Don't run queries. Just creates Groonga database",
241
+ "(#{@run_queries})") do |boolean|
242
+ @run_queries = boolean
217
243
  end
218
244
  parser.on("--skip-finished-queries",
219
245
  "Don't run finished query logs.") do
@@ -411,9 +437,10 @@ module GroongaQueryLog
411
437
  def server_options
412
438
  options = {
413
439
  :load_data => @load_data,
414
- :run_queries => @run_queries,
415
- :recreate_database => @recreate_database,
416
440
  :output_query_log => @output_query_log,
441
+ :recreate_database => @recreate_database,
442
+ :run_queries => @run_queries,
443
+ :warm_up => @warm_up,
417
444
  }
418
445
  directory_options.merge(options)
419
446
  end
@@ -448,19 +475,23 @@ module GroongaQueryLog
448
475
  end
449
476
 
450
477
  def old_groonga_server
478
+ options = server_options
479
+ options[:warm_up_commands] = @old_groonga_warm_up_commands
451
480
  GroongaServer.new(@old_groonga,
452
481
  @old_groonga_options,
453
482
  @old_groonga_env,
454
483
  @old_database,
455
- server_options)
484
+ options)
456
485
  end
457
486
 
458
487
  def new_groonga_server
488
+ options = server_options
489
+ options[:warm_up_commands] = @new_groonga_warm_up_commands
459
490
  GroongaServer.new(@new_groonga,
460
491
  @new_groonga_options,
461
492
  @new_groonga_env,
462
493
  @new_database,
463
- server_options)
494
+ options)
464
495
  end
465
496
 
466
497
  def format_report(success,
@@ -558,6 +589,14 @@ module GroongaQueryLog
558
589
  retry
559
590
  end
560
591
 
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)
597
+ end
598
+ end
599
+
561
600
  yield if block_given?
562
601
  end
563
602
 
@@ -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_sorted_elapsed_times
51
+ collect_sorted_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_sorted_elapsed_times
59
+ collect_sorted_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,22 @@ module GroongaQueryLog
66
74
  end
67
75
  end
68
76
 
69
- def choose_target_elapsed_time(responses)
77
+ def collect_sorted_elapsed_times(responses)
70
78
  elapsed_times = responses.collect do |response|
71
79
  response.elapsed_time
72
80
  end
73
- sorted_elapsed_times = elapsed_times.sort
81
+ elapsed_times.sort
82
+ end
83
+
84
+ def choose_target_elapsed_time(responses)
85
+ sorted_elapsed_times = collect_sorted_elapsed_times(responses)
74
86
 
75
87
  strategy = @options.choose_strategy
76
88
  case strategy
77
89
  when :fastest
78
90
  sorted_elapsed_times.first
79
91
  when :median
80
- sorted_elapsed_times[elapsed_times.size / 2]
92
+ sorted_elapsed_times[sorted_elapsed_times.size / 2]
81
93
  else
82
94
  message =
83
95
  "choose strategy must be :fastest or :median: #{strategy.inspect}"
@@ -187,24 +187,38 @@ 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, response1, response2)
192
+ end
193
+ end
194
+
195
+ def verify_performance(command, response1, response2)
191
196
  responses1 = [response1]
192
197
  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
198
  verifier = PerformanceVerifier.new(command,
199
199
  responses1,
200
200
  responses2,
201
201
  @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])
202
+ return unless verifier.slow?
203
+
204
+ n_tries = 4
205
+ n_tries.times do
206
+ responses1 << groonga1_client.execute(command)
207
+ responses2 << groonga2_client.execute(command)
208
+ verifier = PerformanceVerifier.new(command,
209
+ responses1,
210
+ responses2,
211
+ @options.performance_verifier_options)
212
+ if verifier.slow?
213
+ @slow = true
214
+ @events.push([:slow,
215
+ command,
216
+ verifier.old_elapsed_time,
217
+ verifier.new_elapsed_time,
218
+ verifier.old_sorted_elapsed_time,
219
+ verifier.new_sorted_elapsed_time])
220
+ return
221
+ end
208
222
  end
209
223
  end
210
224
 
@@ -233,11 +247,18 @@ module GroongaQueryLog
233
247
  output.flush
234
248
  end
235
249
 
236
- def report_slow(output, command, old_elapsed_time, new_elapsed_time)
250
+ def report_slow(output,
251
+ command,
252
+ old_elapsed_time,
253
+ new_elapsed_time,
254
+ old_sorted_elapsed_times,
255
+ new_sorted_elapsed_times)
237
256
  command_source = command.original_source || command.to_uri_format
238
257
  output.puts("command: #{command_source}")
239
258
  output.puts("elapsed_time_old: #{old_elapsed_time}")
240
259
  output.puts("elapsed_time_new: #{new_elapsed_time}")
260
+ output.puts("elapsed_times_old: #{old_sorted_elapsed_times.join(' ')}")
261
+ output.puts("elapsed_times_new: #{new_sorted_elapsed_times.join(' ')}")
241
262
  output.puts("elapsed_time_ratio: #{new_elapsed_time / old_elapsed_time}")
242
263
  output.flush
243
264
  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.2"
18
+ VERSION = "1.6.7"
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.2
4
+ version: 1.6.7
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-09 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