Commit 114ea29c authored by Stan Hu's avatar Stan Hu

Speed up boot time in production

In production mode, eager loading is enabled, and Devise is configured
by default to reload routes before eager loading. However, in
`config/application.rb` we also attempted to reload routes, which added
another 5-10 seconds of delay. In development mode, eager loading is
disabled, so we don't see this extra overhead.

To speed boot times, we only reload the routes if eager loading is
disabled.

Relates to https://gitlab.com/gitlab-org/gitlab/-/issues/213992
parent f0af9f07
---
title: Speed up boot time in production
merge_request: 33929
author:
type: performance
......@@ -301,7 +301,10 @@ module Gitlab
end
config.after_initialize do
Rails.application.reload_routes!
# Devise (see initializers/8_devise.rb) already reloads routes if
# eager loading is enabled, so don't do this twice since it's
# expensive.
Rails.application.reload_routes! unless config.eager_load
project_url_helpers = Module.new do
extend ActiveSupport::Concern
......
......@@ -6,6 +6,11 @@ Devise.setup do |config|
manager.default_strategies(scope: :user).unshift :two_factor_backupable
end
# This is the default. This makes it explicit that Devise loads routes
# before eager loading. Disabling this seems to cause an error loading
# grape-entity `expose` for some reason.
config.reload_routes = true
# ==> Mailer Configuration
# Configure the class responsible to send e-mails.
config.mailer = "DeviseMailer"
......
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