Skip to content

Log failed BatchCount queries

What does this MR do?

In order to bring more details about failing batch queries we need to log them. This MR adds logging to BatchCount module.

Benchmark with benchmark-ips on 20 000 000 rows in ci_builds table comparing version form master and this branch

benchmark source
require 'benchmark/ips'

Benchmark.ips do |x|
  x.report('without logging') do
    Gitlab::UsageData.send(:usage_activity_by_stage_secure,{ created_at: 30.days.ago..2.days.ago });
  end

  x.save! 'bench_logging'
  x.compare!
end
Warming up --------------------------------------
        with logging     1.000  i/100ms
Calculating -------------------------------------
        with logging      0.630  (± 0.0%) i/s -      4.000  in   6.349144s

Comparison:
     without logging:        0.6 i/s
        with logging:        0.6 i/s - 1.00x  (± 0.00) slower

=> #<Benchmark::IPS::Report:0x00007ffc6e7307b8
 @data=nil,
 @entries=
  [#<Benchmark::IPS::Report::Entry:0x00007ffc6e741f40 @iterations=4, @label="without logging", @measurement_cycle=1, @microseconds=6327560.0, @show_total_time=false, @stats=#<Benchmark::IPS::Stats::SD:0x00007ffc6e743688 @error=0, @mean=0.6322069521719502, @samples=[0.6244976696869455, 0.6292201005619565, 0.6391581520148183, 0.6359518864240807]>>,
   #<Benchmark::IPS::Report::Entry:0x00007ffc793ae350 @iterations=4, @label="with logging", @measurement_cycle=1, @microseconds=6349144.0, @show_total_time=true, @stats=#<Benchmark::IPS::Stats::SD:0x00007ffc793ae490 @error=0, @mean=0.6300365432139545, @samples=[0.6242707737024689, 0.6282701461105051, 0.6362355216654101, 0.631369731377434]>>]>

Screenshots

Does this MR meet the acceptance criteria?

Conformity

(https://docs.gitlab.com/ee/development/documentation/workflow.html#when-documentation-is-required))

Edited by Mikołaj Wawrzyniak

Merge request reports