Commit 787fd117 authored by Matthias Käppler's avatar Matthias Käppler

Merge branch '350270-drop-memory-static-ci-job' into 'master'

Drop `memory-static` CI job code

See merge request gitlab-org/gitlab!79442
parents 4ad1da5e 1d28dd8f
...@@ -11,36 +11,9 @@ ...@@ -11,36 +11,9 @@
metrics: "${METRICS_FILE}" metrics: "${METRICS_FILE}"
expire_in: 31d expire_in: 31d
# Disabled since it causes intermittent SIGSEGV in CI:
# https://gitlab.com/gitlab-org/gitlab/-/issues/350296
.memory-static:
extends: .only-code-memory-job-base
stage: test
needs: ["setup-test-env"]
variables:
SETUP_DB: "false"
MEMORY_BUNDLE_MEM_FILE: "tmp/memory_bundle_mem.txt"
MEMORY_BUNDLE_OBJECTS_FILE: "tmp/memory_bundle_objects.txt"
script:
# Uses two different reports from the 'derailed_benchmars' gem.
# Loads each of gems in the Gemfile and checks how much memory they consume when they are required.
# 'derailed_benchmarks' internally uses 'get_process_mem'
- bundle exec derailed bundle:mem > "${MEMORY_BUNDLE_MEM_FILE}"
- scripts/generate-gems-size-metrics-static "${MEMORY_BUNDLE_MEM_FILE}" >> "${METRICS_FILE}"
# Outputs detailed information about objects created while gems are loaded.
# 'derailed_benchmarks' internally uses 'memory_profiler'
- bundle exec derailed bundle:objects > "${MEMORY_BUNDLE_OBJECTS_FILE}"
- scripts/generate-gems-memory-metrics-static "${MEMORY_BUNDLE_OBJECTS_FILE}" >> "${METRICS_FILE}"
artifacts:
paths:
- "${METRICS_FILE}"
- "${MEMORY_BUNDLE_MEM_FILE}"
- "${MEMORY_BUNDLE_OBJECTS_FILE}"
# Show memory usage caused by invoking require per gem. # Show memory usage caused by invoking require per gem.
# Unlike `memory-static`, it hits the app with one request to ensure that any last minute require-s have been called. # Hits the app with one request to ensure that any last minute require-s have been called.
# The application is booted in `production` environment. # The application is booted in `production` environment.
# All tests are run without a webserver (directly using Rack::Mock by default). # All tests are run without a webserver (directly using Rack::Mock by default).
memory-on-boot: memory-on-boot:
......
#!/usr/bin/env ruby
# frozen_string_literal: true
abort "usage: #{__FILE__} <memory_bundle_objects_file_name>" unless ARGV.length == 1
memory_bundle_objects_file_name = ARGV.first
full_report = File.readlines(memory_bundle_objects_file_name)
allocated_str = full_report[1]
retained_str = full_report[2]
allocated_stats = /Total allocated: (?<bytes>.*) bytes \((?<objects>.*) objects\)/.match(allocated_str)
retained_stats = /Total retained: (?<bytes>.*) bytes \((?<objects>.*) objects\)/.match(retained_str)
abort 'failed to process the benchmark output' unless allocated_stats && retained_stats
puts "memory_static_objects_allocated_mb #{(allocated_stats[:bytes].to_f / (1024 * 1024)).round(1)}"
puts "memory_static_objects_retained_mb #{(retained_stats[:bytes].to_f / (1024 * 1024)).round(1)}"
puts "memory_static_objects_allocated_items #{allocated_stats[:objects]}"
puts "memory_static_objects_retained_items #{retained_stats[:objects]}"
#!/usr/bin/env ruby
# frozen_string_literal: true
abort "usage: #{__FILE__} <memory_bundle_mem_file_name>" unless ARGV.length == 1
memory_bundle_mem_file_name = ARGV.first
full_report = File.readlines(memory_bundle_mem_file_name)
def total_size(memory_bundle_mem_report)
stats = /TOP: (?<total_mibs_str>.*) MiB/.match(memory_bundle_mem_report.first)
abort 'failed to process the benchmark output' unless stats
"gem_total_size_mb #{stats[:total_mibs_str].to_f.round(1)}"
end
TOP_LEVEL_GEM_LOG_FORMAT = /^ (?<gem_name>\S.*):\s*(?<gem_size>\d[.\d]*)\s*MiB/.freeze
def all_gems(memory_bundle_mem_report)
memory_bundle_mem_report.map do |line|
TOP_LEVEL_GEM_LOG_FORMAT.match(line)
end.compact
end
def gems_as_metrics(gems_match_data)
gems_match_data.map do |gem|
gem_name = gem[:gem_name]
gem_size_mb = gem[:gem_size].to_f.round(1)
"gem_size_mb{name=\"#{gem_name}\"} #{gem_size_mb}"
end
end
puts total_size(full_report)
puts gems_as_metrics(all_gems(full_report)).sort(&:casecmp)
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