diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-16 21:09:21 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-16 21:09:21 +0000 |
commit | 87af6f2e0590af0ed1bb3e5de1bb5d21855a94d2 (patch) | |
tree | 2abe2661b10cf6281bc03855b3053a072c64fbbf /lib/gitlab/diff | |
parent | c43ba2677f41ad0b5fc6f3af6baf4266c70dfcb3 (diff) | |
download | gitlab-ce-87af6f2e0590af0ed1bb3e5de1bb5d21855a94d2.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/diff')
-rw-r--r-- | lib/gitlab/diff/highlight_cache.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/gitlab/diff/highlight_cache.rb b/lib/gitlab/diff/highlight_cache.rb index 3940b3fca4b..e79127108b4 100644 --- a/lib/gitlab/diff/highlight_cache.rb +++ b/lib/gitlab/diff/highlight_cache.rb @@ -101,6 +101,8 @@ module Gitlab # redis.expire(key, EXPIRATION) end + + record_memory_usage(fetch_memory_usage(redis, key)) end # Subsequent read_file calls would need the latest cache. @@ -109,6 +111,23 @@ module Gitlab clear_memoization(:cacheable_files) end + def record_memory_usage(memory_usage) + if memory_usage + self.class.gitlab_redis_diff_caching_memory_usage_bytes.observe({}, memory_usage) + end + end + + def fetch_memory_usage(redis, key) + # Redis versions prior to 4.0.0 do not support memory usage reporting + # for a specific key. As of 11-March-2020 we support Redis 3.x, so + # need to account for this. We can remove this check once we + # officially cease supporting versions <4.0.0. + # + return if Gem::Version.new(redis.info["redis_version"]) < Gem::Version.new("4") + + redis.memory("USAGE", key) + end + def file_paths strong_memoize(:file_paths) do diff_files.collect(&:file_path) |