diff options
author | Sean McGivern <sean@gitlab.com> | 2019-04-02 09:27:17 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-04-02 09:27:17 +0000 |
commit | d7583addf21cd4299363a5ce64126c37ca4234ea (patch) | |
tree | 9a0c5e005c6fa103702f695f824093e5850ccb61 /lib | |
parent | 91d884ec6b6d636308d74635a5895957b5246c24 (diff) | |
parent | 8686e01250824e475dc9412c399c44100878a71e (diff) | |
download | gitlab-ce-d7583addf21cd4299363a5ce64126c37ca4234ea.tar.gz |
Merge branch 'sh-fix-rugged-tree-entries' into 'master'
Avoid excessive recursive calls with Rugged TreeEntries
Closes #59759
See merge request gitlab-org/gitlab-ce!26813
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/git/rugged_impl/tree.rb | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/gitlab/git/rugged_impl/tree.rb b/lib/gitlab/git/rugged_impl/tree.rb index 0ebfd496695..bb13d114d46 100644 --- a/lib/gitlab/git/rugged_impl/tree.rb +++ b/lib/gitlab/git/rugged_impl/tree.rb @@ -15,12 +15,23 @@ module Gitlab override :tree_entries def tree_entries(repository, sha, path, recursive) if Feature.enabled?(:rugged_tree_entries) - tree_entries_from_rugged(repository, sha, path, recursive) + tree_entries_with_flat_path_from_rugged(repository, sha, path, recursive) else super end end + def tree_entries_with_flat_path_from_rugged(repository, sha, path, recursive) + tree_entries_from_rugged(repository, sha, path, recursive).tap do |entries| + # This was an optimization to reduce N+1 queries for Gitaly + # (https://gitlab.com/gitlab-org/gitaly/issues/530). It + # used to be done lazily in the view via + # TreeHelper#flatten_tree, so it's possible there's a + # performance impact by loading this eagerly. + rugged_populate_flat_path(repository, sha, path, entries) + end + end + def tree_entries_from_rugged(repository, sha, path, recursive) current_path_entries = get_tree_entries_from_rugged(repository, sha, path) ordered_entries = [] @@ -32,13 +43,6 @@ module Gitlab ordered_entries.concat(tree_entries_from_rugged(repository, sha, entry.path, true)) end end - - # This was an optimization to reduce N+1 queries for Gitaly - # (https://gitlab.com/gitlab-org/gitaly/issues/530). It - # used to be done lazily in the view via - # TreeHelper#flatten_tree, so it's possible there's a - # performance impact by loading this eagerly. - rugged_populate_flat_path(repository, sha, path, ordered_entries) end def rugged_populate_flat_path(repository, sha, path, entries) |