diff options
author | Rémy Coutable <remy@rymai.me> | 2017-06-16 14:32:44 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-06-16 14:32:44 +0300 |
commit | 98a49dc54004beda18c999bb11ceb0713d46ba9d (patch) | |
tree | 3dca2ce7d662cdc5f0220cd249d8ba7c33f73b64 | |
parent | a4449d880e5454188d9fdb31631bda0d160b2a9b (diff) | |
parent | fe0898cc14606ec0cc0ca57db9d21bf1424f290f (diff) |
Merge branch 'speed-up-graphs' into 'master'
Speed up used languages calculation on charts page
See merge request !12212
-rw-r--r-- | changelogs/unreleased/speed-up-graphs.yml | 4 | ||||
-rw-r--r-- | config/initializers/rugged_use_gitlab_git_attributes.rb | 25 |
2 files changed, 29 insertions, 0 deletions
diff --git a/changelogs/unreleased/speed-up-graphs.yml b/changelogs/unreleased/speed-up-graphs.yml new file mode 100644 index 00000000000..7cb155af6fd --- /dev/null +++ b/changelogs/unreleased/speed-up-graphs.yml @@ -0,0 +1,4 @@ +--- +title: Speed up used languages calculation on charts page +merge_request: +author: diff --git a/config/initializers/rugged_use_gitlab_git_attributes.rb b/config/initializers/rugged_use_gitlab_git_attributes.rb new file mode 100644 index 00000000000..7d652799786 --- /dev/null +++ b/config/initializers/rugged_use_gitlab_git_attributes.rb @@ -0,0 +1,25 @@ +# We don't want to ever call Rugged::Repository#fetch_attributes, because it has +# a lot of I/O overhead: +# <https://gitlab.com/gitlab-org/gitlab_git/commit/340e111e040ae847b614d35b4d3173ec48329015> +# +# While we don't do this from within the GitLab source itself, the Linguist gem +# has a dependency on Rugged and uses the gitattributes file when calculating +# repository-wide language statistics: +# <https://github.com/github/linguist/blob/v4.7.0/lib/linguist/lazy_blob.rb#L33-L36> +# +# The options passed by Linguist are those assumed by Gitlab::Git::Attributes +# anyway, and there is no great efficiency gain from just fetching the listed +# attributes with our implementation, so we ignore the additional arguments. +# +module Rugged + class Repository + module UseGitlabGitAttributes + def fetch_attributes(name, *) + @attributes ||= Gitlab::Git::Attributes.new(path) + @attributes.attributes(name) + end + end + + prepend UseGitlabGitAttributes + end +end |