2019-09-17 10:16:34 -04:00
|
|
|
.only-code-memory-job-base:
|
2019-08-26 16:41:55 -04:00
|
|
|
extends:
|
|
|
|
- .default-retry
|
2020-06-02 08:08:33 -04:00
|
|
|
- .rails-cache
|
2019-08-26 16:41:55 -04:00
|
|
|
- .default-before_script
|
2020-02-18 10:08:51 -05:00
|
|
|
- .memory:rules
|
2021-10-12 17:09:47 -04:00
|
|
|
variables:
|
|
|
|
METRICS_FILE: "metrics.txt"
|
|
|
|
artifacts:
|
|
|
|
reports:
|
|
|
|
metrics: "${METRICS_FILE}"
|
|
|
|
expire_in: 31d
|
2019-09-17 10:16:34 -04:00
|
|
|
|
|
|
|
memory-static:
|
|
|
|
extends: .only-code-memory-job-base
|
2020-02-20 13:08:51 -05:00
|
|
|
stage: test
|
2020-05-13 20:07:47 -04:00
|
|
|
needs: ["setup-test-env"]
|
2019-08-26 16:41:55 -04:00
|
|
|
variables:
|
|
|
|
SETUP_DB: "false"
|
2021-10-12 17:09:47 -04:00
|
|
|
MEMORY_BUNDLE_MEM_FILE: "tmp/memory_bundle_mem.txt"
|
|
|
|
MEMORY_BUNDLE_OBJECTS_FILE: "tmp/memory_bundle_objects.txt"
|
2019-06-13 11:14:06 -04:00
|
|
|
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'
|
2021-10-12 17:09:47 -04:00
|
|
|
- bundle exec derailed bundle:mem > "${MEMORY_BUNDLE_MEM_FILE}"
|
|
|
|
- scripts/generate-gems-size-metrics-static "${MEMORY_BUNDLE_MEM_FILE}" >> "${METRICS_FILE}"
|
2019-06-13 11:14:06 -04:00
|
|
|
|
|
|
|
# Outputs detailed information about objects created while gems are loaded.
|
|
|
|
# 'derailed_benchmarks' internally uses 'memory_profiler'
|
2021-10-12 17:09:47 -04:00
|
|
|
- bundle exec derailed bundle:objects > "${MEMORY_BUNDLE_OBJECTS_FILE}"
|
|
|
|
- scripts/generate-gems-memory-metrics-static "${MEMORY_BUNDLE_OBJECTS_FILE}" >> "${METRICS_FILE}"
|
2019-06-13 11:14:06 -04:00
|
|
|
artifacts:
|
|
|
|
paths:
|
2021-10-12 17:09:47 -04:00
|
|
|
- "${METRICS_FILE}"
|
|
|
|
- "${MEMORY_BUNDLE_MEM_FILE}"
|
|
|
|
- "${MEMORY_BUNDLE_OBJECTS_FILE}"
|
2019-06-25 08:11:06 -04:00
|
|
|
|
|
|
|
# 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:
|
2019-08-26 16:41:55 -04:00
|
|
|
extends:
|
2019-09-17 10:16:34 -04:00
|
|
|
- .only-code-memory-job-base
|
2021-05-10 08:10:26 -04:00
|
|
|
- .use-pg12
|
2020-02-20 13:08:51 -05:00
|
|
|
stage: test
|
2020-06-02 08:08:33 -04:00
|
|
|
needs: ["setup-test-env", "compile-test-assets"]
|
2019-06-25 08:11:06 -04:00
|
|
|
variables:
|
|
|
|
NODE_ENV: "production"
|
|
|
|
RAILS_ENV: "production"
|
|
|
|
SETUP_DB: "true"
|
2021-10-12 17:09:47 -04:00
|
|
|
MEMORY_ON_BOOT_FILE: "tmp/memory_on_boot.txt"
|
2019-06-25 08:11:06 -04:00
|
|
|
script:
|
2021-10-12 17:09:47 -04:00
|
|
|
- PATH_TO_HIT="/users/sign_in" CUT_OFF=0.3 bundle exec derailed exec perf:mem >> "${MEMORY_ON_BOOT_FILE}"
|
|
|
|
- scripts/generate-memory-metrics-on-boot "${MEMORY_ON_BOOT_FILE}" >> "${METRICS_FILE}"
|
2019-06-25 08:11:06 -04:00
|
|
|
artifacts:
|
|
|
|
paths:
|
2021-10-12 17:09:47 -04:00
|
|
|
- "${METRICS_FILE}"
|
|
|
|
- "${MEMORY_ON_BOOT_FILE}"
|