Merge branch '62722-boot-app-in-ci-and-check-memory-ce' into 'master'
Get memory data after booting app in production Closes #62722 See merge request gitlab-org/gitlab-ce!30185
This commit is contained in:
commit
5996377936
4 changed files with 41 additions and 5 deletions
|
@ -17,3 +17,26 @@ memory-static:
|
||||||
- tmp/memory_*.txt
|
- tmp/memory_*.txt
|
||||||
reports:
|
reports:
|
||||||
metrics: tmp/memory_metrics.txt
|
metrics: tmp/memory_metrics.txt
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
# The application is booted in `production` environment.
|
||||||
|
# All tests are run without a webserver (directly using Rack::Mock by default).
|
||||||
|
memory-on-boot:
|
||||||
|
extends: .rspec-metadata-pg-10
|
||||||
|
variables:
|
||||||
|
NODE_ENV: "production"
|
||||||
|
RAILS_ENV: "production"
|
||||||
|
SETUP_DB: "true"
|
||||||
|
SKIP_STORAGE_VALIDATION: "true"
|
||||||
|
# we override the max_old_space_size to prevent OOM errors
|
||||||
|
NODE_OPTIONS: --max_old_space_size=3584
|
||||||
|
script:
|
||||||
|
# Both bootsnap and derailed monkey-patch Kernel#require, which leads to circular dependency
|
||||||
|
- DISABLE_BOOTSNAP=true PATH_TO_HIT="/users/sign_in" CUT_OFF=0.3 bundle exec derailed exec perf:mem >> 'tmp/memory_on_boot.txt'
|
||||||
|
- scripts/generate-memory-metrics-on-boot tmp/memory_on_boot.txt >> 'tmp/memory_on_boot_metrics.txt'
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- tmp/memory_*.txt
|
||||||
|
reports:
|
||||||
|
metrics: tmp/memory_on_boot_metrics.txt
|
||||||
|
|
|
@ -3,7 +3,7 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
||||||
# Set up gems listed in the Gemfile.
|
# Set up gems listed in the Gemfile.
|
||||||
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
||||||
begin
|
begin
|
||||||
require 'bootsnap/setup'
|
require 'bootsnap/setup' unless ENV['DISABLE_BOOTSNAP']
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
# bootsnap is an optional dependency, so if we don't have it, it's fine
|
# bootsnap is an optional dependency, so if we don't have it, it's fine
|
||||||
end
|
end
|
||||||
|
|
11
scripts/generate-memory-metrics-on-boot
Executable file
11
scripts/generate-memory-metrics-on-boot
Executable file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
abort "usage: #{__FILE__} <memory_bundle_mem_file_name>" unless ARGV.length == 1
|
||||||
|
memory_bundle_mem_file_name = ARGV.first
|
||||||
|
|
||||||
|
full_report = File.open(memory_bundle_mem_file_name).read
|
||||||
|
|
||||||
|
stats = /TOP: (?<total_mibs_str>.*) MiB/.match(full_report)
|
||||||
|
abort 'failed to process the benchmark output' unless stats
|
||||||
|
|
||||||
|
puts "total_memory_used_by_dependencies_on_boot_prod_env_mb #{stats[:total_mibs_str].to_f.round(1)}"
|
|
@ -35,9 +35,11 @@ sed -i 's/username: root/username: gitlab/g' config/database.yml
|
||||||
|
|
||||||
if [ "$GITLAB_DATABASE" = 'postgresql' ]; then
|
if [ "$GITLAB_DATABASE" = 'postgresql' ]; then
|
||||||
sed -i 's/localhost/postgres/g' config/database.yml
|
sed -i 's/localhost/postgres/g' config/database.yml
|
||||||
|
sed -i 's/username: git/username: postgres/g' config/database.yml
|
||||||
|
|
||||||
if [ -f config/database_geo.yml ]; then
|
if [ -f config/database_geo.yml ]; then
|
||||||
sed -i 's/localhost/postgres/g' config/database_geo.yml
|
sed -i 's/localhost/postgres/g' config/database_geo.yml
|
||||||
|
sed -i 's/username: git/username: postgres/g' config/database_geo.yml
|
||||||
fi
|
fi
|
||||||
else # Assume it's mysql
|
else # Assume it's mysql
|
||||||
sed -i 's/localhost/mysql/g' config/database.yml
|
sed -i 's/localhost/mysql/g' config/database.yml
|
||||||
|
@ -48,16 +50,16 @@ else # Assume it's mysql
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cp config/resque.yml.example config/resque.yml
|
cp config/resque.yml.example config/resque.yml
|
||||||
sed -i 's/localhost/redis/g' config/resque.yml
|
sed -i 's|url:.*$|url: redis://redis:6379|g' config/resque.yml
|
||||||
|
|
||||||
cp config/redis.cache.yml.example config/redis.cache.yml
|
cp config/redis.cache.yml.example config/redis.cache.yml
|
||||||
sed -i 's/localhost/redis/g' config/redis.cache.yml
|
sed -i 's|url:.*$|url: redis://redis:6379/10|g' config/redis.cache.yml
|
||||||
|
|
||||||
cp config/redis.queues.yml.example config/redis.queues.yml
|
cp config/redis.queues.yml.example config/redis.queues.yml
|
||||||
sed -i 's/localhost/redis/g' config/redis.queues.yml
|
sed -i 's|url:.*$|url: redis://redis:6379/11|g' config/redis.queues.yml
|
||||||
|
|
||||||
cp config/redis.shared_state.yml.example config/redis.shared_state.yml
|
cp config/redis.shared_state.yml.example config/redis.shared_state.yml
|
||||||
sed -i 's/localhost/redis/g' config/redis.shared_state.yml
|
sed -i 's|url:.*$|url: redis://redis:6379/12|g' config/redis.shared_state.yml
|
||||||
|
|
||||||
if [ "$SETUP_DB" != "false" ]; then
|
if [ "$SETUP_DB" != "false" ]; then
|
||||||
setup_db
|
setup_db
|
||||||
|
|
Loading…
Reference in a new issue