Eager load controller actions to reduce response time of the first request #29559
On the first request,
This also reduces the memory footprint when running on forking server like Unicorn.
all credit goes to @casperisfine. I'm just pushing this patch from Shopify into upstream
On the first request, ActionController::Base#action_methods computes and memoized the list of available actions . 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.  https://github.com/rails/rails/blob/a3813dce9a0c950a4af7909111fa730a2622b1db/actionpack/lib/abstract_controller/base.rb#L66-L77
@matthewd I tried it and the problem is that when
In contrast, when we do it in
Do you think it's a bigger problem that we should fix?
Ah, hrmm. I was just looking at
At a more fundamental level, if we can't even implement our own eager loading using the callback designed for it...
Maybe we should be splitting eager loading into two phases, constant loading vs "extra" loading/preparation?
Or maybe this is fine as it is. It just feels weird to me -- these components shouldn't really know about