From 5b1332bb4d3c3aa5215b43004d1e7f6a8d376dd0 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Wed, 11 Jan 2017 14:50:42 +0100 Subject: Fully initialize routes before the first request is handled `AD::Journey::GTG::Simulator` is lazily built the first time `Journey::Router#find_routes` is invoked, which happens when the first request is served. On large applications with many routes, building the simulator can take several hundred milliseconds (~700ms for us). Triggering this initialization during the boot process reduces the impact of deploys on the application response time. --- actionpack/lib/action_dispatch/routing/route_set.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'actionpack/lib/action_dispatch/routing') diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 5853adb110..5b873aeab7 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -349,6 +349,12 @@ module ActionDispatch @formatter = Journey::Formatter.new self end + def eager_load! + router.eager_load! + routes.each(&:eager_load!) + nil + end + def relative_url_root @config.relative_url_root end -- cgit v1.2.3