Skip to content

Tree performance improvements

Ramya Authappan requested to merge github/fork/rspeicher/tree_performance into master

Created by: rspeicher

After speeding up the Commits page a bit, I started on the Tree page.

Surprisingly, the single biggest bottleneck was the tree_icon helper. I simplified it, but at the cost of only having two icons: one for folders, one for not-folders. I think it's a worthy tradeoff.

Benchmark code

# Run tree_icon on GitLab's root tree 10 times

require 'benchmark'
require_relative 'config/environment'

p = Project.find_by_code('gitlabhq')
t = p.repo.tree.contents

include TreeHelper

def image_tag(*args)
end

Benchmark.bm do |x|
  x.report { 10.times { t.each { |v| tree_icon(v) } } }
end

Results:

master          1.590000  24.690000  26.280000 ( 26.290603)
performance     0.000000   0.000000   0.000000 (  0.000202)

Crazy, right?

The rest of the PR is just some refactoring of the tree views. Removes a bunch of logic from them that either wasn't necessary or better fit in a helper.

Finally, I updated Grit to the 2.5.0 official gem (I did it looking for any performance improvements, but we might as well switch to it anyway).

Merge request reports

Loading