diff options
author | Kir Shatrov <shatrov@me.com> | 2017-06-24 10:57:36 -0400 |
---|---|---|
committer | Kir Shatrov <shatrov@me.com> | 2017-07-29 14:03:52 +0300 |
commit | 0668c22a41e4c88ccb7600fc5b4bfb1a5b76e45d (patch) | |
tree | 83ab792d98f40879901860712248559a8a1ebc27 /actionmailer | |
parent | 904f1a8747958129124d86b44e36c5f0263e0125 (diff) | |
download | rails-0668c22a41e4c88ccb7600fc5b4bfb1a5b76e45d.tar.gz rails-0668c22a41e4c88ccb7600fc5b4bfb1a5b76e45d.tar.bz2 rails-0668c22a41e4c88ccb7600fc5b4bfb1a5b76e45d.zip |
Eager load controller and mailer actions
On the first request, ActionController::Base#action_methods computes
and memoized the list of available actions [1]. With this PR we move
this expensive operation into eager load step to reduce response time
of the first request served in production.
This also reduces the memory footprint when running on forking server
like Unicorn.
[1] https://github.com/rails/rails/blob/a3813dce9a0c950a4af7909111fa730a2622b1db/actionpack/lib/abstract_controller/base.rb#L66-L77
Diffstat (limited to 'actionmailer')
-rw-r--r-- | actionmailer/lib/action_mailer/railtie.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/actionmailer/lib/action_mailer/railtie.rb b/actionmailer/lib/action_mailer/railtie.rb index 36c2e5866d..69578471b0 100644 --- a/actionmailer/lib/action_mailer/railtie.rb +++ b/actionmailer/lib/action_mailer/railtie.rb @@ -58,6 +58,12 @@ module ActionMailer end end + initializer "action_mailer.eager_load_actions" do + ActiveSupport.on_load(:after_initialize) do + ActionMailer::Base.descendants.each(&:action_methods) if config.eager_load + end + end + config.after_initialize do |app| options = app.config.action_mailer |