summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/danger/helper.rb1
-rw-r--r--lib/gitlab/diff/highlight_cache.rb19
-rw-r--r--lib/gitlab/repository_cache_adapter.rb2
-rw-r--r--lib/gitlab/set_cache.rb17
-rw-r--r--lib/gitlab/usage_data.rb4
5 files changed, 38 insertions, 5 deletions
diff --git a/lib/gitlab/danger/helper.rb b/lib/gitlab/danger/helper.rb
index 50a68c2e2c4..c5174da4b7c 100644
--- a/lib/gitlab/danger/helper.rb
+++ b/lib/gitlab/danger/helper.rb
@@ -133,6 +133,7 @@ module Gitlab
%r{\A(\.gitlab-ci\.yml\z|\.gitlab\/ci)} => :engineering_productivity,
%r{\A\.overcommit\.yml\.example\z} => :engineering_productivity,
%r{\Atooling/overcommit/} => :engineering_productivity,
+ %r{\A.editorconfig\z} => :engineering_productivity,
%r{Dangerfile\z} => :engineering_productivity,
%r{\A(ee/)?(danger/|lib/gitlab/danger/)} => :engineering_productivity,
%r{\A(ee/)?scripts/} => :engineering_productivity,
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)
diff --git a/lib/gitlab/repository_cache_adapter.rb b/lib/gitlab/repository_cache_adapter.rb
index 304f53b58c4..688a4a39dba 100644
--- a/lib/gitlab/repository_cache_adapter.rb
+++ b/lib/gitlab/repository_cache_adapter.rb
@@ -237,7 +237,7 @@ module Gitlab
end
def expire_redis_set_method_caches(methods)
- methods.each { |name| redis_set_cache.expire(name) }
+ redis_set_cache.expire(*methods)
end
def expire_redis_hash_method_caches(methods)
diff --git a/lib/gitlab/set_cache.rb b/lib/gitlab/set_cache.rb
index 0927a3e64bb..2e72855824a 100644
--- a/lib/gitlab/set_cache.rb
+++ b/lib/gitlab/set_cache.rb
@@ -14,8 +14,11 @@ module Gitlab
"#{key}:set"
end
- def expire(key)
- with { |redis| redis.del(cache_key(key)) }
+ def expire(*keys)
+ with do |redis|
+ keys = keys.map { |key| cache_key(key) }
+ unlink_or_delete(redis, keys)
+ end
end
def exist?(key)
@@ -51,5 +54,15 @@ module Gitlab
def with(&blk)
Gitlab::Redis::Cache.with(&blk) # rubocop:disable CodeReuse/ActiveRecord
end
+
+ def unlink_or_delete(redis, keys)
+ if Feature.enabled?(:repository_set_cache_unlink, default_enabled: true)
+ redis.unlink(*keys)
+ else
+ redis.del(*keys)
+ end
+ rescue ::Redis::CommandError
+ redis.del(*keys)
+ end
end
end
diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb
index 6da238e61b9..b9cd4d74914 100644
--- a/lib/gitlab/usage_data.rb
+++ b/lib/gitlab/usage_data.rb
@@ -66,8 +66,8 @@ module Gitlab
clusters_disabled: count(::Clusters::Cluster.disabled),
project_clusters_disabled: count(::Clusters::Cluster.disabled.project_type),
group_clusters_disabled: count(::Clusters::Cluster.disabled.group_type),
- clusters_platforms_eks: count(::Clusters::Cluster.aws_installed.enabled, batch: false),
- clusters_platforms_gke: count(::Clusters::Cluster.gcp_installed.enabled, batch: false),
+ clusters_platforms_eks: count(::Clusters::Cluster.aws_installed.enabled),
+ clusters_platforms_gke: count(::Clusters::Cluster.gcp_installed.enabled),
clusters_platforms_user: count(::Clusters::Cluster.user_provided.enabled),
clusters_applications_helm: count(::Clusters::Applications::Helm.available),
clusters_applications_ingress: count(::Clusters::Applications::Ingress.available),