Commit cbb90e51 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'add-profiling-env' into 'master'

Add ENV['RAILS_PROFILE'] to the development env

See merge request gitlab-org/gitlab!26516
parents a50711df 02f2c67f
......@@ -50,4 +50,14 @@ Rails.application.configure do
# BetterErrors live shell (REPL) on every stack frame
BetterErrors::Middleware.allow_ip!("127.0.0.1/0")
# Reassign some performance related settings when we profile the app
if Gitlab::Utils.to_boolean(ENV['RAILS_PROFILE'].to_s)
warn "Hot-reloading is disabled as you are running with RAILS_PROFILE enabled"
config.cache_classes = true
config.eager_load = true
config.active_record.migration_error = false
config.active_record.verbose_query_logs = false
config.action_view.cache_template_loading = true
end
end
......@@ -120,3 +120,16 @@ Bullet will log query problems to both the Rails log as well as the Chrome
console.
As a follow up to finding `N+1` queries with Bullet, consider writing a [QueryRecoder test](query_recorder.md) to prevent a regression.
## Settings that impact performance
1. `development` environment by default works with hot-reloading enabled, this makes Rails to check file changes every request, and create a potential contention lock, as hot reload is single threaded.
1. `development` environment can load code lazily once the request is fired which results in first request to always be slow.
To disable those features for profiling/benchmarking set the `RAILS_PROFILE` environment variable to `true` before starting GitLab. For example when using GDK:
- create a file [`env.runit`](https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/master/doc/runit.md#modifying-environment-configuration-for-services) in the root GDK directory
- add `export RAILS_PROFILE=true` to your `env.runit` file
- restart GDK with `gdk restart`
*This environment variable is only applicable for the development mode.*
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