Skip to content

Speed up Gitlab::Git::Repository#log

username-removed-7736 requested to merge hiroponz/gitlab_git:speed-up-log into master

What does this MR do?

Use Rugged::Walker if can in Gitlab::Git::Repository#log

What are the relevant issue numbers?

https://gitlab.com/gitlab-org/gitlab-ce/issues/13808

Benchmark

script

require 'benchmark/ips'

Benchmark.ips do |x|
  repo = Gitlab::Git::Repository.new("/Users/satouhiroyuki/project/gitlab_git/.git")

  x.report("log_by_walk") { repo.log({ ref: "master", offset: 0, limit: 40 }) }
  x.report("log_by_shell") { repo.log({ ref: "master", offset: 0, limmit: 40, disable_walk: true }) }

  # Compare the iterations per second of the various reports!
  x.compare!
end

result

Warming up --------------------------------------
         log_by_walk   129.000  i/100ms
        log_by_shell    11.000  i/100ms
Calculating -------------------------------------
         log_by_walk      1.301k (± 9.8%) i/s -      6.450k
        log_by_shell    118.614  (± 2.5%) i/s -    594.000

Comparison:
         log_by_walk:     1300.8 i/s
        log_by_shell:      118.6 i/s - 10.97x slower

Merge request reports

Loading