Commit bbbdb704 authored by Ahmad Sherif's avatar Ahmad Sherif

Merge branch 'mk-gc-requests' into 'master'

Run GC major collection after each request

See merge request gitlab-org/gitlab-exporter!131
parents 5784090e 999a1bc6
Pipeline #183258 passed with stage
in 2 minutes and 21 seconds
......@@ -35,6 +35,21 @@ module GitLab
end
end
# Performs a major GC after each request. We found that this helps to free up
# several MB of memory in conjunction with sricter malloc config.
# See https://gitlab.com/gitlab-org/gitlab/-/issues/297241
class RunGC
def initialize(app)
@app = app
end
def call(env)
@app.call(env).tap do
GC.start
end
end
end
class << self
DEFAULT_WEB_SERVER = "webrick".freeze
......@@ -45,6 +60,10 @@ module GitLab
memory_threshold = (config[:server] && config[:server][:memory_threshold]) || 1024
use MemoryKillerMiddleware, memory_threshold
use Rack::Logger
use RunGC
# Defrag heap after everything is loaded into memory.
GC.compact
end
def logger
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment